troyvw
asked on
what does this code do? Int(txtTEst.Text)
what does this code do? Int(txtTEst.Text). txtest is a textbox.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ty
Remember to check the textbox's text before converting, otherwise it will throw an error.
Like this:
Dim iValue as Integer
If IsNumeric(txtTEst.Text) then
iValue = CInt(txtTEst.Text)
End If
Like this:
Dim iValue as Integer
If IsNumeric(txtTEst.Text) then
iValue = CInt(txtTEst.Text)
End If
ASKER
What if i wanted it to retain the decimal? for example if i entered 1.3
Then use CDbl to convert to double, or CSng to convert to single, or CDec to convert to decimal. All of them will retain the decimal.
"The name 'Int' does not exist in the current context"
because .net compiler searches method Int(string data).
If it does not exist then gives error else calls implemented method.