Results 1 to 1 of 1

Thread: VB - Validating Clipboard Data before Pasting

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295

    VB - Validating Clipboard Data before Pasting

    Frequently, a textbox will be intended to accept specific types of data, ie: currency values, other numeric input or any custom formatted data. When using the standard textbox, this situation brings up the problem of the user pasting the wrong type of data into the textbox. While it is always possible to validate this input in the Change event or at some other convenient and logical point in your code, it may be desirable to prevent the improper data from being pasted in the first place.

    The attached example subclasses the textbox to intercept the windows Paste message. The code can then validate the text stored on the clipboard and take appropriate action if it does not fit the criteria for the textbox.

    This example was written to allow multiple textboxes to be subclassed simultaneously.

    Please note: When running this project in the VB IDE, it is important to close the project by the 'Exit' button or the form's control box. Stopping execution of the program by using the 'Stop' command from the IDE toolbar or menu will cause the project and VB to crash immediately, loosing any unsaved changes.

    (There are steps you can take to protect yourself, however these are beyond the scope of this example.)
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width