Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Box Asking for Date, and Validating Format Paige Excel Programming 3 May 23rd 06 12:32 AM
validating input of textbox before publishing eyesonly1965 Excel Programming 4 May 7th 06 03:18 PM
validating Ayesha Excel Worksheet Functions 2 April 26th 06 02:56 PM
validating input in textbox Jean-Pierre D via OfficeKB.com Excel Programming 1 August 15th 05 08:37 PM
Validating user input to a listbox Stuart[_5_] Excel Programming 3 September 6th 03 07:32 AM


All times are GMT +1. The time now is 06:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"