input mask of textbox

  • Thread starter Thread starter Cheung
  • Start date Start date
C

Cheung

Guest
Hey, Can I add input mask of a textbox controls in a windows form?
my requirement is simple, when user type in number, the textbox automatically displays the format "###,###.00" .
use type: 123456
the textbox shows : 123,456.00

THANKS!!
 
its all gotta be hardcoded

heres the way id do it

Code:
sub txt_textaddwhateverevent(key as integer, shift as integer) handles txt.keydown
Dim fj as string
if key >= 48 and key <=57 then
    if len(txt.text) > 3 then
           if mid(txt.text, len(txt.text)-3, 3) = ".00" then
                 fj = mid(txt.text, 1, len(txt.text)-3)
           else
                 fj = txt.text
           end if
     else
        fj = txt.text
     end if
    if len(fj) mod 3 = 0 then
          fj = fj & ","
    end if
    txt.text = fj & ".00"
else
   txt.text = mid(txt.text, 1, len(txt.text)-1)
end if
end sub

i know its not pretty, but from the way u describe what u want to happen this should work. u can of course modify it to work exactly the way you want it to.
 
Back
Top