Login | |
|
 |
RE: stumped - 4/6/2006 6:32:14 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1193
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Hmm... you might think about breaking up your case else statement? Either that or do like ebgreen suggested, and use select case true and have one of the cases be Input = "" Case Else If Len(Trim(Input)) = 0 Then MsgBox ("That is an incorrect entry, try again") getInput Else quit = MsgBox ("Are you sure?", 36, "Want To quit?")'52 If quit = 6 Then MsgBox ("Bye!!") WScript.Quit Else getInput End If
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: stumped - 4/6/2006 2:18:39 PM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
i guess i should be more specific. i am testing for user input, with error checking. here is what i want to happen, 1. clicking ok with nothing in the field: error message with reload of menu 2. clicking cancel: goes to "Want to quit" msgbox 3. hitting esc or clicking to close the inputbox: goes to "Want to quit" msgbox clicking ok with nothing in the field returns an empty string clicking cancel returns an empty variable hitting esc or clicking to close the inputbox returns an empty variable select case will only check string variables, i was hoping to keep my code smaller and cleaner by keeping all my error checking in the select case. when i test for case "" this returns true for all the above a select cast true still wouldnt work because it would be true for both variable types. in other words, when testing for an empty variable if typename(input) = "Empty" then tests true only for #3 and case "" tests true for all 3 i guess ill just use the if/then to test for an empty variable, i just wanted to be able to test for it in the select case.
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
 |
RE: stumped - 4/6/2006 2:42:03 PM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
here is an example of what i DONT want: sub getUserName() Username = InputBox("Enter your admin username (domain\username)", "Enter Username") if username = "" then MsgBox ("That is an incorrect entry, try again") getUserName() end if end sub getUserName() there is NO WAY to break out of the loop without entering something, other than killing the process that spawned it. this works: (watch the typename echo when you run it and youll see what im getting at) sub getUserName() Username = InputBox("Enter your admin username (domain\username)", "Enter Username") wscript.echo typename(username) if typename(username) = "Empty" then MsgBox ("Closing the inputbox") wscript.quit elseif username = "" then MsgBox ("That is an incorrect entry, try again") getUserName() end if end sub getUserName() as you can see you HAVE to test for the empty variable BEFORE testing for an empty string because it returns true for an empty string AND an empty variable my original goal was to try and do this in a select/case rather than using if/elseif btw, im feeling very BOLD tonight lol
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
 |
RE: stumped - 4/7/2006 12:52:54 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1193
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
I was about to suggest that instead of using inputbox, you put together a very simple HTA, or ie page since that way you can assign various values to the ok, cancel buttons, etc.
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
 |
RE: stumped - 4/7/2006 1:54:09 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
quote:
ORIGINAL: DiGiTAL.SkReAM I was about to suggest that instead of using inputbox, you put together a very simple HTA, or ie page since that way you can assign various values to the ok, cancel buttons, etc. That was a possiblity as well, I'd rather throw in an if/then than rewrite the whole script though.
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
|
|