0

Hi everyone,
I need to use integer that is typed into textbox to do some math functions.
here is what i have:

Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
dim x as integer
dim y as integer
dim tbox as integer

tbox = (Textbox1.Text)
x = (y / tbox) * 100

if (x >= 50) then
'do something

end if
End Sub

when i press button it keeps saying that conversion from string "" to type 'Integer' is not valid!
how do i fix it?
i've tried
tbox = CInt(Textbox1.Text)
and
tbox = Ctype(Textbox1.Text, Integer)
but its not working :(

2
Contributors
1
Reply
9
Views
4 Years
Discussion Span
Last Post by TnTinMN
0

Use one of these forms of parsing:

i = Integer.Parse("1") - will throw an exception if conversion is not possible
Integer.TryParse("1", i) - will not throw exception, leaves i unchanged

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.