Link to home
Start Free TrialLog in
Avatar of troyvw
troyvwFlag for United States of America

asked on

what does this code do? Int(txtTEst.Text)

what does this code do? Int(txtTEst.Text).  txtest is a textbox.
Avatar of Vipul Patel
Vipul Patel
Flag of India image

Gives below error
"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.
ASKER CERTIFIED SOLUTION
Avatar of Zhaolai
Zhaolai
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of troyvw

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

Avatar of troyvw

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.