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
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