Solved

Check textbox input for invalid entries

Posted on 2014-11-26
4
66 Views
Last Modified: 2014-11-26
I have 2 textboxs that make a filename
txtName and txtAddress
I know there are characters or symbols that are not allowed in a filename
Example FileName:
John Doe 1124 Address.st
How can determine the wrong entries as they are typed and popup a message box
Call MsgBox(" These symbols not allowed: ????
0
Comment
Question by:isnoend2001
  • 3
4 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40467110
Would you rather want to prevent them from being entered in the first place?
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40467133
Try this.
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
    ' These are the characters "<>?[]:|*!" which aren't allowed
    Case 33, 42, 124, 58, 93, 91, 63, 62, 60
        Beep
        KeyAscii = 0
End Select
End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40467165
Thanks Marty, just what i needed
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40467173
Glad I could help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now