I need a little help with a Visual Basic .NET program

XBoxLPU

Diamond Member
Aug 21, 2001
4,249
1
0
I have the program working 100% just fine. The only annoyance is that when I hit the computate button, I have to hit it twice for the actual computation to work. IE, when I first load up the program, select one of the 4 choices from the combobox dropdown, input some values, the result comes up 0, but I hit compute again it shows the correct value

Hmmm ???

 

oog

Golden Member
Feb 14, 2002
1,721
0
0
The Select Case statement that does the calculation for V occurs after you convert V into the Volume variable and put it into your result string. One a second click of the compute button the variable V still has its old value.
 

XBoxLPU

Diamond Member
Aug 21, 2001
4,249
1
0
Originally posted by: oog
The Select Case statement that does the calculation for V occurs after you convert V into the Volume variable and put it into your result string. One a second click of the compute button the variable V still has its old value.

n/m

I got it! Put the convert to string for voume after the calcuation, then the messagebox stuff!


Thanks
 

UCJefe

Senior member
Jan 27, 2000
302
0
0
If you did this, what would you expect to happen?

Volume = V
V = L*W*H
MessageBox.Show(Volume, "Volume")

You are copying V into Volume, changing V, and then displaying Volume. Changing V obviously has no effect on Volume in case that's the area of confusion. You need to do all your operations to calculate V and THEN put that into your string.

And to answer your question about why all your other variables work, it's because you initialize them with the correct values BEFORE constructing your string which you don't do with V.