Guest Cheung Posted May 23, 2002 Posted May 23, 2002 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!! Quote
Guest Cheung Posted May 23, 2002 Posted May 23, 2002 also, how can I limit the textbox to accept only numbers?? thx Quote
Guest littledump Posted May 23, 2002 Posted May 23, 2002 its all gotta be hardcoded heres the way id do it 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. Quote
Guest Cheung Posted May 24, 2002 Posted May 24, 2002 Thanks a lot. I need to write code like this?! that's fine and I will try. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.