MedVision ad

vb-textboxes (1 Viewer)

sasquatch

Member
Joined
Aug 15, 2005
Messages
384
Gender
Male
HSC
2006
For your first problem, i dont know why that happens but alternatively you can use the format number function:

Code:
Label1.Caption = FormatNumber(Label1.Caption, 2, vbTrue, vbFalse, vbTrue)
This will set the format of the label as #,###.##.


For the second problem, a type mismatch error occurs when you attempt to assign an data type differing to the declared data type of the variable or property you are setting to. The ListIndex property is of an integer data type, so make sure your assigning only an integer. If your using a statement similar to:

combo1.ListIndex = variable,

make sure that the variable is declared as an integer.
 

{*(00)*}

New Member
Joined
Jun 8, 2005
Messages
29
Location
sydney
Gender
Male
HSC
2006
my program has a couple of glitches and problems.
when a different data type is entered into a textbox, an error occurs, is there a way to make a messagebox appear to say that a proper data type is to be inputted?

the scrollbars that i make don't work like want it to. it doesn't increment properly and doesn't work when you click the position where you want the value to be.also, whenever i go in one direction it keeps going in that direction unless you keep pressing it.

the comboboxes, i want them to help change the caption of label1 and alter the formula a little. eg. if you select weekly then the label changes to weekly and the label would print out the weekly repayment. atm it only prints out the monthly repayment.

also, could you check my intrinsic documentation layout.
what do you think of my project?
 
Last edited:

sasquatch

Member
Joined
Aug 15, 2005
Messages
384
Gender
Male
HSC
2006
First problem:

In the Command1_Click() subroutine, change it to something like the following:

Code:
Private Sub Command1_Click()

On Error Goto ErrorHandling

Dim loan As Double
Dim months As Double
Dim rate As Double

    If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
        MsgBox "please fill in all the details before proceeding"
    Else

loan = Text1.Text
months = Text2.Text
rate = Text3.Text

Label1.Caption = Round(((rate / 1200) * (1 + (rate / 1200)) ^ months * loan) / (((1 + (rate / 1200)) ^ months) - 1), 2)
Label2.Caption = Round(Label1.Caption * months, 2)
Label6.Caption = "$"
Label7.Caption = ""
Label8.Caption = ""

End If

Call DrawGraph

Exit Sub
ErrorHandling:

Msgbox "The data you entered was invalid. Please correct this before re-calculating", vbInformation, "Invalid Data"
End Sub
The reason why your scrollbars are all screwy is cuz of this bit
Code:
Text2.Text = Text2 + scrollvalue
cant you see that your "Adding" the value of the text to the value of the scrollbar.

if you want it to start from say 300, just do this

Code:
Text2.Text = 300 + scrollvalue
Otherwise each time you click it it changes all weird...

3rd Problem. If you would like to change the label depending on an item selected in a combo box, you could do something like the following:

Code:
Private Sub Combo1_Click()
    LabelObject.Caption = Combo1.Text
End Sub
Then when you calculate the weekly/monthly/etc payment you can assign the label to correct data by using a select case statement.

Code:
Select Case Combo1.Text
    Case "weekly"
        'Do whatever
    Case "monthly"
        'do whater"
End Select
About your intrinsic documentation, its ok for the decleration of the variables and the indenting. But even the objects should be given intrinsic identifers. A convention that is used in the labeling of objects followings something like the following:

cmdQuit (command button)
lblWelcome (label)
picGraph (picture box/picture)
mnuFile (menu)
txtName (text box)

Apart from using the three-letter abbreviation indicating the nature of the objects you should also give it a meaningful name (as shown above), rather than just label1, label2, label3. You might remember what they mean now, but for a person not-related to your project, it will be confusing to understand what the code means.

I think your project is pretty good overall. One thing you could fix however is by having capitialisation for the text within your project. You have everything all lower-case, and i guess it looks a bit lazy. Also for your combobox, you have it "style" property set to "0 - Dropdown combo", where combo refers to a comfbination input AND selection. I think for this case you only need selection (as entering anything else would probably be meaningless, and may cause errors) so you can change it's style to "2 - Dropdown list".
 
Last edited:

{*(00)*}

New Member
Joined
Jun 8, 2005
Messages
29
Location
sydney
Gender
Male
HSC
2006
haha, thanks man. you're a pretty smart guy for someone that's doing the hsc , with all this knowledge of vb and all. i wonder how you find the time to study and help others on bored of studies?
 

sasquatch

Member
Joined
Aug 15, 2005
Messages
384
Gender
Male
HSC
2006
{*(00)*} said:
haha, thanks man. you're a pretty smart guy for someone that's doing the hsc , with all this knowledge of vb and all. i wonder how you find the time to study and help others on bored of studies?
Nuh im not. I started learning vb in year 8.. and yeah its a very easy language to learn if you take the time in doing so. also i dont really help that many people, but thanks for the compliments..hehe..
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top