473,791 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Test for integer

Rob
I have a 3 character string that I want to test to see if it is a positive
integer... I could test that each individual character is >=0 and <=9... is
there a better way ?

Is there an IsInteger() function ?
Jan 6 '06 #1
3 8693
"Rob" <rw*****@comcas t.net> schrieb:
I have a 3 character string that I want to test to see if it is a positive
integer... I could test that each individual character is >=0 and <=9... is
there a better way ?

If you are using .NET 2.0, you may want to use 'Integer.TryPar se'. In .NET
1.0/1.1 you can use 'Integer.Parse' + exception handling. Maybe using
'IsNumeric' is an option too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 6 '06 #2

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ub******** ******@TK2MSFTN GP11.phx.gbl...
"Rob" <rw*****@comcas t.net> schrieb:
I have a 3 character string that I want to test to see if it is a positive
integer... I could test that each individual character is >=0 and <=9...
is there a better way ?

If you are using .NET 2.0, you may want to use 'Integer.TryPar se'. In
.NET 1.0/1.1 you can use 'Integer.Parse' + exception handling. Maybe
using 'IsNumeric' is an option too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Hmm, I have wondered for a long while why they didn't make a TryParse for
Integer...they did for Double...

<shrug>

:)

Mythran

Jan 7 '06 #3
You can read the historic reason for the existence Double.TryParse in
previous versions at:

http://msdn.microsoft.com/msdnmag/is...t/default.aspx

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio 2005, Visual Studio .NET,
VB6, VB5 and VBA
You can code, design and document much faster in VB.NET, C#, C++ or VJ#
Free resources for add-in developers:
http://www.mztools.com

"Mythran" <ki********@hot mail.comREMOVET RAIL> escribió en el mensaje
news:Oe******** *****@TK2MSFTNG P10.phx.gbl...


Hmm, I have wondered for a long while why they didn't make a TryParse for
Integer...they did for Double...

<shrug>

:)

Mythran

Jan 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

467
21705
by: mike420 | last post by:
THE GOOD: 1. pickle 2. simplicity and uniformity 3. big library (bigger would be even better) THE BAD:
15
51678
by: deko | last post by:
What I'd like to do is create an array of values and test for existence of those values. Here's the non-working code I'm having trouble with: Dim wcSearch(4 To 7) As Integer If Me.Value = wcSearch Then Do Something Else Do Something else
35
2585
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C# newsgroup on 25 September. The regular expressions where in that newsgroup too involved. I told yesterday night, to Jay that I would test all 4 methods and the stupid method I was thinking of the first time that night when I saw Jon's
2
1769
by: Greg | last post by:
Please note: I have cross posted this from Newsgroup: microsoft.public.dotnet.framework.aspnet.webservices with a few minor changes... I am having a simple problem setting up the security on my test web service... My Web service code is: Imports System.Web.Services
11
18307
by: sara | last post by:
I am trying my first functions in my code. I have a set of queries that runs to create temp tables with the right data for some reports. They can run for a long time, so I want the user to know what is in the tables (date parameters) before running all the queries. This way, if the data in the tables is not for the time period the user needs for reporting, s/he knows to recreate the data. I just want to find the data in the tables and...
5
2397
by: Little | last post by:
I have this program and I need to work on the test portion, which tests if a Val is in the list. It returns false no matter what could you look at the part and see what might need to be done to fix it. It reads in the file and sorts out the files into the four different lists. F.txt int main 2 " " help
1
2005
by: starffly | last post by:
In my program, the calculated value is supposed to be no more than the constants named MAXINT,otherwise, the overflow error will be reported, however, I cannot test if the value exceeds MAXINT within the integer scope smaller than MAXINT, so I want to seek a solution to test the excess without comparing the value with MAXINT. Please let me know if you have a good idea. THX.
7
30216
by: laura | last post by:
Hi, I have a variable of type double. I need to know if there is an integer number store there. How can I test that ? I also have a default precision for doing this operation. Many thanks, Laura
0
1079
by: Raghunandan24 | last post by:
Hi, Does anyone know how to write cactus test cases to test this servlet. public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html");
0
9669
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
9517
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
10428
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...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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
5435
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...
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
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.