Hi Im using VIsualbasic2005 Express (its .net of course )
Dim intText1 As Double
Dim intText2 As Integer
Dim intText3 As Double
intText1 = Val(Frm3.TextBox1.
intText2 = Val(Frm3.TextBox2.
intText3 = CDbl(Val(Frm3.TextBox2.
Frm3.TextBox3.Text = intText3
Textbox3 is still 0
When textbox1 = 0.04
and textbox2 = 456
the problem is the Third teextbox3 is just givine me 3 and not the value of Textbox1(0.04) * Textbox2(400)

Having trouble getting a correct value of textbox3
Peer Larsen
Try to put your code inside an event handler like the Form_load
1. Double click on your Form3, it will take you into code Form_load event
2. Add your code into the event, showing below
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim intText1 As Double
Dim intText2 As Integer
Dim intText3 As DoubleintText1 = Val(
Me.TextBox1.Text) 'Here is says Conversion from string "" to type 'Long' is not valid.intText2 = Val(
Me.TextBox2.Text)intText3 =
CDbl(Val(Me.TextBox2.Text) * Val(Me.TextBox1.Text))
Me.TextBox3.Text = intText3 End SubAmir5656
I still didnt find anything
can you By any chance
run me thorugh on what you mean set the text in the designerClay Borkholm
Actually, what my other reply did not address is that you're assuming that there are valid numeric values in the text boxes. You can use double.tryparse to check this in your code, and thus handle any potential error.
Jcl71
Visual Basic Fan
Ok i set back and thought about it
I took in mind about a button press
Your right a button press is much better
Becuase if i use the Form_Load event how can i Tell the values of Textbox1 and textbox2 to be multiplied and displayed and textbox3 if the form hasnt loaded already
so i have added an extra button just for that task :D
kroyce
In the design view, where you can see your form, you can set the initial text values for the textboxes in their properties. If you didn't do this, the form_load event will fire while your text boxes are empty ( or worse, contain something like TextBox1 ). If you set the values there, then they will be visible in the text boxes when the form loads.
After you set the break point, F5 from memory steps through the code a line at a time. Break the code down as much as possible, so you can see the result of each step. Do the textboxes contain the numbers you expect Do they get converted successfully to an int and a double Do those two values get added together correctly What's being passed to the text of the third text box When you break it down like this, you can see the exact step at which things are starting to go awry.
Cycling is too much fun
rodizzio
Now you should make both variables doubles, and use double.tryparse to check if both strings are valid doubles before the rest of your code runs.
jamesbf
What do you mean if the set it set in the designer
do you mean like go into the Property window and set some type of text for Textbox3
Nige PJ
Is the text set in the designer If so, then it probably should have worked. Did you try my suggestion Also, you may want to break the code down into the smallest possible steps and walk through it in the debugger to see at what point it's not doing exactly what you expected. I'd add a button, and put that code inside a click event handler for hte button ( just double click in design view to create the method ), then you can call it over and over as you're debugging it.
LeeJames
If you press F9 in the IDE you can set what's called a 'breakpoint'. When you hit F5 to run your program, the execution will stop here, and you can step throug hthe code a line at a line and examime the state of your variables as you go.
LeonidVo
Why would his text boxes have these values already defined on form load Surely a button click is a better idea
Moe A
bcw
Yep i have done that
it works now thank you guys for all your help :P
i usually never run into these kind of problems
but there is a first time for everything.