Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |