
Custom textbox entries....Keypress question
Calan,
Have a look in the messages posted today in the comp.lang.visual.basic for a
the thread with subject "AutoFormat TextBox Entry: ab1234 --> AB 1234". In
particular, look at the 2 messages from me (Rob Strover). They may provide
a start for you to do what you require.
After you've looked there, if you've any questions about the postings please
feel free to ask me.
BTW, I noticed after I posted the second message that I'd left out a few
vital lines of code, not that, in any case, the code covers all
possiblities. [it's not been checked *that* well :-)]
(1) A variable declaration at start of Text1_Change sub:
Static bSpaceInserted As Boolean
and
(2) immediately after the sCurrLastChar = Right$(sText, 1) line:
If sPrevLastChar = Space$(1) Then
bSpaceInserted = False
End If
Quote:
> I need a textbox that will only accept values in the range of -4.00 to
3.00
> (i.e. -2.33, 1.24, -3.99, etc)
> The problem is:
> 1. I want to allow the "-" character, but only as the first digit (do not
> allow ".3-2" for example).
> 2. I would like the text box to automatically display the ".", if the
first
> digit is 1 to 4, or the first two digits are -1 to -4.
> 3. I want to disallow any number > 4 in position 2 (if pos 1 is "-", or
> disallow anything > 3 in position 1 if nothing has been entered.
> Is this going overboard on input validation? I'll be validating the actual
> value on lostfocus; I realize I could just limit a value like "9.232" to
> "3.00".
> I've looked at the masked edit box, but it doesn't give me anything in the
> way of allowing the "-" character, and I'm not crazy about it anyway.
> Anybody have any fancy smancy keypress, text changed type code to do this?
> Otherwise I'll probably just use another control for the "+" or "-" (would
> rather not though).
> Thanks,
> Calan