Click here to Skip to main content
Licence 
First Posted 14 Mar 2005
Views 40,087
Bookmarked 12 times

Function to check numeric data

By | 14 Mar 2005 | Article
This function returns True if the specified data is in digits and returns False if it is not in digits.

Introduction

This is simple function (written in VB.Net) which tells whether the given string is in digits or not.

Description

To check this I will simply make two functions:
1- Page_Load(Sender As Object, E As EventArgs)
2- Check_For_Numeric_Format(C_S)

We will declare one variable in Page_Load e.g., "Var_String", assign it the value and then call the function "Check_For_Numeric_Format(Var_String)". The code is given below:

Source Code

Sub Page_Load(Sender As Object, E As EventArgs)<BR>   If Not Page.IsPostBack Then<BR>    Dim Var_String<BR>    Var_String = "1234567890"<BR>    If Check_For_Numeric_Format(Var_String) = True Then<BR>     Response.Write("Congratulations! The string is in digits.")<BR>    Else<BR>     Response.Write("Sorry! The string is not in digits.")<BR>    End If<BR>   End If<BR>End Sub<BR><BR>Function Check_For_Numeric_Format(C_S)<BR>   Dim Var_Loop, Var_Len<BR>   If C_S = "" Then<BR>    Return False<BR>   End If<BR>   Var_Len = Len(C_S)<BR>   C_S = LCase(C_S)<BR>   For Var_Loop = 1 To Var_Len<BR>    If Mid(C_S, Var_Loop, 1) < Chr(48) Or Mid(C_S, Var_Loop, 1) > Chr(57) Then<BR>     Return False<BR>    End If<BR>   Next<BR>   Return True<BR>End Function

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

naveedmazhar



Pakistan Pakistan

Member

I am a computer science graduate. I have been working in ASP.Net since January 2003.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAwful ! PinmemberDynV8:49 5 Jul '07  
Question.what? PinsussAnonymous2:14 15 Mar '05  
AnswerRe: .what? PinsussAnonymous2:15 15 Mar '05  
Questionwhat with 4.32, -33, ? Pinmemberloui3119:44 14 Mar '05  
AnswerRe: what with 4.32, -33, ? Pinmembernaveedmazhar15:02 15 Mar '05  
GeneralRe: what with 4.32, -33, ? PinsussAnonymous22:05 23 Aug '05  
QuestionHuh? PinmemberPoolbeer19:00 14 Mar '05  
AnswerRe: Huh? PinsussAnonymous19:41 4 May '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 14 Mar 2005
Article Copyright 2005 by naveedmazhar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid