Solved

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

Posted on 2010-09-14
6
345 Views
Last Modified: 2012-05-10
what does this code do? Int(txtTEst.Text).  txtest is a textbox.
0
Comment
Question by:troyvw
  • 3
  • 2
6 Comments
 
LVL 5

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.
0
 
LVL 17

Accepted Solution

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

Author Closing Comment

by:troyvw
ID: 33675550
ty
0
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

by:Zhaolai
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

0
 

Author Comment

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

Expert Comment

by:Zhaolai
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.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - String Manipulation Scenario 2 29
How to filter by key press ? 6 56
How can I do Unit Testing with Session ? 1 23
ASP.NET - Why is accordion not working? 3 49
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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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