• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

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

what does this code do? Int(txtTEst.Text).  txtest is a textbox.
0
troyvw
Asked:
troyvw
  • 3
  • 2
1 Solution
 
Vipul Patel.NET ExpertCommented:
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.
0
 
ZhaolaiCommented:
It should be CInt(txtTEst.Text), which converts the text in the textbox to an integer.
0
 
troyvwAuthor Commented:
ty
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

0
 
troyvwAuthor Commented:
What if i wanted it to retain the decimal? for example if i entered 1.3
0
 
ZhaolaiCommented:
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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now