NationStates Jolt Archive


Can anyone help me with a visual basic program I'm doing?

Schitzophenia
15-10-2005, 17:49
What is wrong with this?

Private Sub Cmdcalculate_Click()
Dim dbllength As Double
Dim dblwidth As Double

dbllength = txtlength.Text
dblwidth = txtwidth.Text
dblra = dbllength * dblwidth

lblarea.Caption = dblra
End Sub
Safalra
15-10-2005, 17:54
Can anyone help me with a visual basic program I'm doing?
If you're programming in Visual Basic then you're beyond help. Just kidding, of course - someone was bound to make the joke, so it may as well be me.
Schitzophenia
15-10-2005, 17:56
Ha ha.
XD
Yeah, I know, pathetic.
But I needed an excuse to play solitare.
PasturePastry
15-10-2005, 17:58
What is wrong with this?

Private Sub Cmdcalculate_Click()
Dim dbllength As Double
Dim dblwidth As Double

dbllength = txtlength.Text
dblwidth = txtwidth.Text
dblra = dbllength * dblwidth

lblarea.Caption = dblra
End Sub
My guess would be a variable type mismatch. Try using the val() function to convert your text to numeric values.

i.e.
dbllength = val(txtlength.Text)
dblwidth = val(txtwidth.Text)
Schitzophenia
15-10-2005, 18:00
My guess would be a variable type mismatch. Try using the val() function to convert your text to numeric values.

i.e.
dbllength = val(txtlength.Text)
dblwidth = val(txtwidth.Text)


I needed to define dblra the same way I defined dbllength and dblwidth.
XD
I'm a smart cookie.
Thanks everyone!
Cheese penguins
15-10-2005, 21:58
i just thought i would brag now and say i made a fully functional web browser capable of FTP and internet chat through online applications in visual basic without a hitch! :D (rant over) o and it is bloody faster than IE whatever and firefox adn for a 100kb app it is bloody good... and so far no viruses or spyware... mind you i aint really used it.
Skaladora
15-10-2005, 23:32
dblra = dbllength * dblwidth


There's your error. You have to use either the + or & operator to concatenate character chains. So replace your * for a & and you should be doing fine.