After all i used jon4747 's ascii codes and thats all.
As a wise man once said "There is more than one way to skin a cat."
I did it my own way because i hate the look of masks and they arent very appealing to the end user.
The maskedbox is for a calculator that calculates tax to be witheld. So the user is going to be using the maskedbox as easy to use as possible.
AND THIS IS WHAT I COME UP WITH.
It works and will support any combination of entry into maskedbox without error. (unless you can find one)
to download the program goto
well in about an hour
oh and if you have vb (everyone here does) press "I HAVE GOT THE DRIVERS"
ok here it is
Private Sub MaskEdBox1_Change()
If Len(MaskEdBox1.Text) >= 1 Then
If MaskEdBox1.Text = "$" Then
Exit Sub
ElseIf MaskEdBox1.Text = "." Then
Exit Sub
ElseIf MaskEdBox1.Text = "$." Then
Exit Sub
ElseIf Not IsNumeric(MaskEdBox1.Text) Then
MaskEdBox1.Text = Left(MaskEdBox1.Text, Len(MaskEdBox1.Text) - 1)
MaskEdBox1.SelStart = Len(MaskEdBox1.Text)
End If
End If
End Sub
Private Sub check()
If dol >= 2 Then
If Len(MaskEdBox1.Text) >= 2 Then
If Not IsNumeric(MaskEdBox1.Text) Then
MaskEdBox1.Text = Left(MaskEdBox1.Text, Len(MaskEdBox1.Text) - 1)
MaskEdBox1.SelStart = Len(MaskEdBox1.Text)
End If
End If
End If
If dec >= 2 Then
If Len(MaskEdBox1.Text) >= 1 Then
If Not IsNumeric(MaskEdBox1.Text) Then
MaskEdBox1.Text = Left(MaskEdBox1.Text, Len(MaskEdBox1.Text) - 1)
MaskEdBox1.SelStart = Len(MaskEdBox1.Text)
End If
End If
End If
End Sub
Private Sub MaskEdBox1_KeyPress(KeyAscii As Integer)
If KeyAscii = 36 Then
dol = dol + 1
check
End If
If KeyAscii = 46 Then
dec = dec + 1
check
End If
End Sub
Private Sub MaskEdBox1_LostFocus()
dol = 0
dec = 0
End Sub
I sincerely do thank all of those people who helped or even thought of helping.
Glad to be a programmer.
Quote for the year by Toastie "VB programmers are nicer, have more ettiquite and are more willing to help others than C or C++ programmers."