by Raghuraja.C (12 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Fri 28th February 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Text Box Currency Valiation code - Text box will allow only 9999.99
'Place following code to form
Private Sub txtAmount_KeyPress(KeyAscii As Integer)
If Len(txtAmount.Text) > 14 Then
KeyAscii = 0
End If
If KeyAscii = 8 Then
Exit Sub
End If
If InStr(1, txtAmount.Text, ".") <> 0 And KeyAscii = 46 Then
KeyAscii = 0
ElseIf InStr(1, txtAmount.Text, ".") <> 0 And (KeyAscii > 47 And KeyAscii < 58) Then
If Len(Mid(txtAmount.Text, (InStr(1, txtAmount.Text, ".") + 1))) >= 2 And txtAmount.SelStart >= InStr(1, txtAmount.Text, ".") Then
KeyAscii = 0
End If
Else
If (KeyAscii > 47 And KeyAscii < 58) Or KeyAscii = 8 Or KeyAscii = 46 Then
Else
KeyAscii = 0
End If
End If
End Sub
No comments have been posted about Text Box Currency Valiation code - Text box will allow only 9999.99. Why not be the first to post a comment about Text Box Currency Valiation code - Text box will allow only 9999.99.