Re: TextBox with comma formatting




"Martin Trump" <martin@xxxxxxxxxxxxxxxxxxx> wrote in message
news:XuLFmGDAQVwIFwKV@xxxxxxxxxxxxxxxxxxxxxx
Hi All

I wish to allow a user to input numbers of up to a million or more.
Simply displayed in a TextBox they're nearly incomprehensible, think
10000000 against 10,000,000.

What I would like to achieve :-

1. If the user inputs numeric characters simply add them to the TextBox
but display them in thousands comma format.

2. If non-numeric then a Beep and ignored

3. However, to allow the user to use CNTR+C, CNTRL+V and allow
insertions and so on. Seems to me that would need oceans of code.

Not posting code 'cos six or more attempts failed so badly, I wouldn't
know which to post.

Help appreciated, TIA
.

A Masked Edit control should work for you. Don't use VB's Google about for a
replacement. Here is a nice one...
http://www.freevbcode.com/ShowCode.Asp?ID=2299

As for your last question, it sort of depends on what your 'default' is when
copying. eg, whether you want a User to highlight and copy "10,000,000" or
"10000000"?

I have often simply provided a small clipboard button to the side which
automatically copys the 'format' or the 'data', or brings up a small dialog
allowing the user to chose. It depends really on how often copy 'n paste is
done.

[You might even want to define your own custom clipboard format.

http://www.vbaccelerator.com/home/VB/Code/Libraries/Clipboard/Customising_Clipboard_Use/article.asp
]

-ralph


.