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 :(

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.