VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



to enter possite or negitive number only

by kvreddy (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 17th December 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

to enter possite or negitive number only

Rate to enter possite or negitive number only



KeyAscii = NumberValue(KeyAscii, CStr(Msk_ritty_comm), Val(Msk_ritty_comm.SelStart))

End Sub


Public Function NumberValue(ByVal Num As Double, ByVal str As Variant, ByVal CursPos As Integer)
If Num <= 42 And Num >= 58 Then
Num = 0
Else
Select Case Num
    Case 48 To 58
    Case 8
    Case 46     '.
            If InStr(1, str, ".", vbTextCompare) Then
                Num = 0
            End If
    Case 45    '-
'        If Len(str) > 1 Then
'            Num = 0
'            Else
'
'            If InStr(1, str, "-", vbTextCompare) Then
'                Num = 0
'            End If
        If Len(str) > 1 And InStr(1, str, "-", vbTextCompare) Then
            Num = 0
            Else
            If Val(str) > 0 And CursPos > 0 Then
                Num = 0
            End If
            If InStr(1, str, "-", vbTextCompare) Then
                Num = 0
            End If
        End If

        
    Case 47    ' /
        Num = 0
    Case 42    ' *
        Num = 0
    Case 43    ' +
        Num = 0
    Case Else
        Num = 0
End Select
End If
NumberValue = Num
End Function

Download this snippet    Add to My Saved Code

to enter possite or negitive number only Comments

No comments have been posted about to enter possite or negitive number only. Why not be the first to post a comment about to enter possite or negitive number only.

Post your comment

Subject:
Message:
0/1000 characters