Visual Basic.Net Help

Status
Not open for further replies.

Nick

Everything to Nothing
Messages
4,053
Location
Wales
I am trying to make a basic converter program on VB.Net however I am having a bit of difficulty as I am very inexperienced with code. I am trying to make a converter so that when you enter a value into one text box, it should output another in another text box.

I am trying to do: Text2 = Text1 multiplied by 5 then divided by 8.

However I have no idea as to what to do!

Cheers.
 
The issue you might be having is the types of the data. I haven't done VB in years and it wasn't .net so I'm sort of shooting in the dark...
Code:
try {
Integer t1 = new Integer(text1.getText());
text2.setText(new Integer((t1 * 5) /8).toString());
} catch (NumberFormatException ex) {
errorHandler("String in first text field could not be converted to a number");
}
Before you get the wrong impression, this code isn't going to compile, certainly not in VB.net. I'm just demonstrating.
 
You would want to do something to the effect of (add your own error handling)...
Text2 = Text1 multiplied by 5 then divided by 8.
Code:
TextBox2.Text = Val(Textbox1.Text) * 5 / 8

Of course, non numeric entries will fail.
 
Status
Not open for further replies.
Back
Top Bottom