Use Masked Edit Box with Variable Length Data from a Database
* Null fields leave the previous value visible in the control, making the user think the data becomes corrupted
* Variable-length data can adversely affect your data. For instance, if you allow 5 or 9 length Zip codes, data sometimes spills over from from record to the next
* If you manually handle the data transfer, you have to be sure to sync up your Mask property with your code.
This generic function ToMask eliminated all these problems for me (at least so far!)
NOTE: The function assumes that the data passed to it does not contain the mask character or any other filler characters. For instance, if you want to display $111.11 in the box pass 11111 as a value, and set the mask property to something like $###.##
Instructions: Copy the declarations and code below and paste directly into your VB project.