# Solved: VB Converting textbox input



## marques_uk (Jun 22, 2009)

Hello, I know this is propbably a fairly easy question to answer but its really annoying me and would love to find the solution to keep me sane.

I want to take the input of a textbox called 'inputTextbox' and add the textbox input as the argument for the method which is called when the button on my form is clicked.

So on click the method guessNumber() is called

fTestClass.guessNumber(inputTextBox.Text) Do I have to use convert.Int32 somewhere?

Thanks in advance
Marques_uk


----------



## omuyelijah (Jan 10, 2006)

Hi

Quite a long time I worked with VB but still can try to help you. In the event handler method for the on-click event of the button in question, u shuld have

_fTestClass.guessNumber(inputTextBox.Text)_

so that the method with can access the inputted value. So u r correct. If however the logic of processing within the method requires conversion of input data (which will come as text) to numeric form, then

_convert.Int32_

will be necessary


----------



## marques_uk (Jun 22, 2009)

Thank you, I thought I was on the right lines. I was trying to convert the textbox input to integer in the argument of the on click. For any one else who might get confused this is what you need to do.

in the on click just use the inputTextBox.Text as your argument

_ fTestClass.guessNumber(inputTextBox.Text)_

In your method guessNumber(ByVal input As String) you need to convert the input String to Integer this is done by creating another variable that will hold your Integer answer and you use the Convert.ToInt32 to convert the String input to guessNo

Dim guessNo As Integer
guessNo = Convert.ToInt32(input)

Now variable guessNo will hold the Integer which has been entered in your textbox, and you can now use this variable in the rest of your program.

All the best
Marques_uk


----------

