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

Posted on 2010-09-14
Last Modified: 2012-05-10
what does this code do? Int(txtTEst.Text).  txtest is a textbox.
Question by:troyvw
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

by:Vipul Patel
ID: 33675497
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.
LVL 17

Accepted Solution

Zhaolai earned 500 total points
ID: 33675540
It should be CInt(txtTEst.Text), which converts the text in the textbox to an integer.

Author Closing Comment

ID: 33675550
Industry Leaders: 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!

LVL 17

Expert Comment

ID: 33675608
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


Author Comment

ID: 33675643
What if i wanted it to retain the decimal? for example if i entered 1.3
LVL 17

Expert Comment

ID: 33675718
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.

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question