473,662 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help on String and Integer

werks
220 New Member
Hi there programmers.

How can you tell if the input value in a textbox is an Integer or String is there any code to know this?
Jan 31 '08 #1
7 1155
daniel aristidou
491 Contributor
Hi there programmers.

How can you tell if the input value in a textbox is an Integer or String is there any code to know this?
Expand|Select|Wrap|Line Numbers
  1.  If isnumeric(textbox.text) = True then
  2. Msgbox("I am a number")
  3. Else
  4. msgbox("I'M not anumber ,im mostlikely a string")
  5. End if
  6.  
This help?
Jan 31 '08 #2
werks
220 New Member
Expand|Select|Wrap|Line Numbers
  1.  If isnumeric(textbox.text) = True then
  2. Msgbox("I am a number")
  3. Else
  4. msgbox("I'M not anumber ,im mostlikely a string")
  5. End if
  6.  
This help?
Thank you! Thank you! Thank You! very much. You saved my day.


Better Than Yesterday ^^
Jan 31 '08 #3
Killer42
8,435 Recognized Expert Expert
I'd just like to point out that by definition, the value in a textbox is always a string. What you're testing is whether it's possible for VB to convert that string to a number. (Note, IsNumeric() function won't care whether it's an integer - it could be too large for instance).

Oh, and a quick tip, daniel. If you're testing a logical value, there's no point in comparing it to True. It already is True or False. So in this example, the code
If IsNumeric(textb ox.Text) = True Then
works exactly the same as
If IsNumeric(textb ox.Text) Then.
Except that depending on how smart the compiler is, the shorter version might execute ever so slightyl faster.
Feb 1 '08 #4
shuvo2k6
68 New Member
Hi there programmers.

How can you tell if the input value in a textbox is an Integer or String is there any code to know this?

TextBox's Text Property must be String, if u want to check Integer, there is no fucntion for that for ur need u must take some other way.
Feb 1 '08 #5
Killer42
8,435 Recognized Expert Expert
TextBox's Text Property must be String, if u want to check Integer, there is no fucntion for that for ur need u must take some other way.
daniel aristidou already provided a solution which "werks" :) though it may have problems with large numbers or decimals.
Feb 1 '08 #6
lotus18
866 Contributor
Oh, and a quick tip, daniel. If you're testing a logical value, there's no point in comparing it to True. It already is True or False. So in this example, the code
If IsNumeric(textb ox.Text) = True Then
works exactly the same as
If IsNumeric(textb ox.Text) Then.
Except that depending on how smart the compiler is, the shorter version might execute ever so slightyl faster.
I didn't know this huh? I learned something new for this day. haha : )

Rey Sean
Feb 1 '08 #7
daniel aristidou
491 Contributor
Hey...killer..y ou have a valid point... i already knew that...i just always put = True in when trying to explain or if there is more than one statement...so as not to get confused.....
Good point though....
Feb 1 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3352
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
0
1485
by: Shaggyh | last post by:
hi im needing help with a program im writing to do subnetting i was on before about it and i got some help. the code below wont work for me and i cant think of why not. i was wondering if anyone out there can help, even come up with a better way of doing this.. i have 2 files.. here is my first file.. // a library assembly i.e. dll
5
2311
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in commented code for anyone else who may be looking to do the same.
11
3002
by: Steve | last post by:
I'm hoping someone can help me out. I'm a newbie to vb.net still. I'm trying to convert the code below from VB6 to VB.NET. I'm not sure of the best way to go. This is basically a simple application to do scoring for a competition. I'm using an Access database and all of this code happens "behind the scenes" when all of the scores have been entered on another screen (that piece is done). If someone could help me, I'd really be...
2
5038
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
4
1951
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal iMsg As Integer, ByVal wParam As Integer, ByVal LParam As Integer) As Integer 'Code here
1
1962
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following statement. Help.ShowHelp(Parent:=Me, url:=Me.HELP_URL_PRE & Me.myWorker.HelpFile) How do I get it to go away when the program exits? Now when I quit the program that I called it form the help file is sill displayed. Is there a way to get a handle...
6
1728
by: carly | last post by:
Hi, im new to java and i really need help with my assigment. I need a simple methode that will: 1- allow a member of a Internet cafe to log in to the workstation 2- log out of the workstation 3- a methode to add a new member to the cafe. 4- a methode to renew the membership
19
1907
by: yxq | last post by:
Hello, I want to get the string resource from DLL file, the code work well for Vista x86, but it will not work on Vista x64, why? can anyone help to view the code below? thank you very much. ////////////////////////////////////////////////////////////////////////////////// Public Class GetResourceStringFromFile Private Declare Function LoadLibrary Lib "kernel32" Alias
13
3504
by: Javad | last post by:
Hello I know that I should get the information of windows internet connections by using "rasapi32.dll" library, and I also have some sample codes, but I can't make them work. My exact need is to get the "UserName" of a connection. How is it possible? plz hlp thnk u
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.