Programmatically Clearing a Text Box

I have a series of text boxes, any subset of which can be used for input of numerical data, followed by a command box to “compute” from that input and write results back to the boxes. If a second, new set of data is to be entered, I would like to automatically clear the boxes when I click a “new” control button. Using the syntax Text1=”” results in a string being read the next time “compute” is clicked and a data type error when a data check is made for non-zero data having been entered. Using the syntax Text1=0 puts a zero in the box, but when I begin typing the new number in, it is as if the keyboard mode is in Ins, rather than Typeover (neither keyboard mode affects the result), and an integer entered is read in with the extra trailing zero making it 10X too large.How can I clear the text boxes back to their uninitialized state that they had when the program was launched, such that they are blank and read as numerical zeros unless non-zero data is entered?

Try the .Clear method on the text box. It is designed not to generate events. Alternatively, if the Clear does generate a Change event, simply set a flag before you clear the box. In the Change event for the text box, if the flag is set, ignore the change that was made. I’ve used this method several times successfully.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may