Writing my own "formatter"?

M

Maury Markowitz

I'd like to allow users to type in things like "1k" and have it understand
that to be 1000. Since the formatter code fires before the Update, it won't
let users type this in unless I remove the number formatter. I'd really
prefer to simply replace it outright.

Does anyone have any examples of how to handle this?
 
A

Allen Browne

If you want to replace "k" with 3 zeros in a number field, use the Change
event of the text box.

Something like this:

Private Sub Text1_Change()
Dim lngPos As Long

With Me.Text1
lngPos = InStr(.Text, "k")
If lngPos > 0 Then
.Text = Left$(.Text, lngPos - 1) & "000" & Mid(.Text, lngPos +
1)
.SelStart = lngPos + 2
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
Top