Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validating Input Box
Hi All
Is there any easy way I can validate the string entered by the user in an input box? I basically don't want the user to enter characters that are considered invalid for file/folder names. i.e., \ / : * ? " < | Will I have to parse the string and check each character one by one or is there any easy way to do it? Ideas appreciated. Thanks Satish |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validating Input Box
Satish,
Using InputBox, you can't do anything until the user click OK and returns the strings. Then you can test it. If you make your own pseudo InputBox with a userform/textbox etc, you can monitor the characters as typed in the KeyDown/KeyPress events and react accordingly. NickHK "Satish" wrote in message oups.com... Hi All Is there any easy way I can validate the string entered by the user in an input box? I basically don't want the user to enter characters that are considered invalid for file/folder names. i.e., \ / : * ? " < | Will I have to parse the string and check each character one by one or is there any easy way to do it? Ideas appreciated. Thanks Satish |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validating Input Box
Look into Regular Expressions. Makes parsing relatively easy. Here is a
quick example that allows only alphanumeric characters and period (code needs refinement, but I think it gives you an idea) Sub ValidateInput() Dim RegExp As Object Dim inputstr, re Set RegExp = CreateObject("VBScript.RegExp") Set re = RegExp re.IgnoreCase = True re.Global = True re.Pattern = "[^a-z0-9\.]" 'Matching pattern are characters that are NOT (indicated by the ^ sign) within a-z, 0-9 or the period character. inputstr = InputBox("Input your string") Do While re.test(inputstr) = True inputstr = InputBox("Please correct your input") Loop MsgBox "Correct/corrected input: " & inputstr End Sub Cheers, Joerg "Satish" wrote in message oups.com... Hi All Is there any easy way I can validate the string entered by the user in an input box? I basically don't want the user to enter characters that are considered invalid for file/folder names. i.e., \ / : * ? " < | Will I have to parse the string and check each character one by one or is there any easy way to do it? Ideas appreciated. Thanks Satish |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Input Box Asking for Date, and Validating Format | Excel Programming | |||
validating input of textbox before publishing | Excel Programming | |||
validating | Excel Worksheet Functions | |||
validating input in textbox | Excel Programming | |||
Validating user input to a listbox | Excel Programming |