VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Make sure TextBox contains a number and determine if the number is an integer

by Imian (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 22nd January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Make sure TextBox contains a number and determine if the number is an integer

Rate Make sure TextBox contains a number and determine if the number is an integer



'######################################################
'#######           Copyright © 2001             #######
'#######    This code was written in VB6 Pro    #######
'#######         by Imian [email protected]         #######
'#######    You can use this code freely in     #######
'####### your projects but if you redistribute  #######
'#######    it leave these Credits Here.        #######
'#######  This sample show a way to understand  #######
'#######   how to determine whether a string    #######
'#######          contains a number.            #######
'######################################################


Option Explicit


Private Function IsNumber(strg As String)
Dim nInt As String

'Check if string contains a number
If IsNumeric(strg) Then

    nInt = Int(strg)
    
'    Check if number is an integer
    If strg = nInt Then
'    Put your code here
      MsgBox "It is an Integer number"
    Else
'    Put your code here
      MsgBox "It is a NON Integer number"
    End If
  
Else
'   Put your code here
    MsgBox "It is NOT a number"
End If
    
    
End Function

Private Sub Command1_Click()
IsNumber Text1.Text
End Sub

Download this snippet    Add to My Saved Code

Make sure TextBox contains a number and determine if the number is an integer Comments

No comments have been posted about Make sure TextBox contains a number and determine if the number is an integer. Why not be the first to post a comment about Make sure TextBox contains a number and determine if the number is an integer.

Post your comment

Subject:
Message:
0/1000 characters