Re: help with loops
- From: "Paul Randall" <paulr901@xxxxxxxxxxxx>
- Date: Sat, 15 Mar 2008 10:57:57 -0600
How about having a function or subroutine that does the common stuff.
Do the unique stuff for each group then call the common routine from
both places.
You might even find it useful to put the unique stuff in a red stuff
routine and a blue stuff routine, calling them from the appropriate
place in the loop, so that the loop is physically smaller and more
understandable.
-Paul Randall
"Steve Jacobs" <sjacobs21@xxxxxxxxxxx> wrote in message
news:7d7bba6b1d578ca54fa660d66cc@xxxxxxxxxxxxxxxxxxxxxxx
Your script works thanks for that. I didn't realise the entire
content would have to be in a loop and this is just my lack of
experience coming out again.
Longer term I have a series of one off scripts which I now have as
separate files, there are no loops or anything like that that perfom
single low complex statements. Eventually these scripts will come
together with this one. Depending on if the user is Blue or Red
Team or both. My only question now remains, if the entire thing is
in a loop how do you break out of it. My initial plan was to add
these code under the case statements for the respective Blue or Red
user groups, and then also have a common scripted lines right at the
end that are to be applied for both groups.
The loop would make things inefficient if I did that as I wouldn't
want everything in the case part to loop, only just the cancel box's
otherwise a lot of code would be processed unnecessarily. This is
certainly the most difficult part of the script, getting everything
to flow.
Hello Pegasus (MVP),
"Steve Jacobs" <sjacobs21@xxxxxxxxxxx> wrote in message
news:7d7bba6b1d288ca5487e98df00c@xxxxxxxxxxxxxxxxxxxxxxx
I'm not sure if this is the kind of thing I was after. Sorry IThe code I posted is very much the kind of thing you wanted. By
wasn't clear so it my fault.
I haven't actually included the code in the sample I provided as I
kept getting an error of Do required or similar.
When I ask
Do Until choice = vbYes
RTeam = InputBox ("What is your Red Team name ?")
The user is confronted with a Input Box, an OK and Cancel option
(3
options). if the user selects cancel I want a loop to go back to
the
following point:
pick = Msgbox("Are you part of Blue Team, Otherwise your on Red
Team",vbYesNoCancel)
I'll provide the scrip again with indents.
deleting one line of code towards the end I achieved the
functionality
you now clarified. Depending on the other functions you require,
you
may not need the "Cancel" variable. Here is the code again:
Do
cancel = False
pick = MsgBox("Are you part of Blue Team, Otherwise your on Red
team",vbYesNoCancel)
If pick = vbYes Then
team = "Blue"
ElseIf pick = vbNo Then
team = "Red"
Else Exit Do
End If
Select Case team
Case "Blue"
Do Until choice = vbYes
BTeam = InputBox ("What is your Blue Team name ?")
If BTeam = Empty Then
cancel = True
Else
MsgBox "Blue Team Name is " & BTeam
End If
Exit Do
Loop
Case "Red"
Do Until choice = vbYes
RTeam = InputBox ("What is your Red Team name ?")
If RTeam = Empty Then
cancel = True
Else
MsgBox("Red Team Name is " & RTeam)
End If
Exit Do
Loop
End Select
Loop
.
- References:
- Re: help with loops
- From: Pegasus \(MVP\)
- Re: help with loops
- From: Steve Jacobs
- Re: help with loops
- Prev by Date: Re: response.write issue
- Next by Date: Search data with vbscript
- Previous by thread: Re: help with loops
- Next by thread: multiple choice boxes
- Index(es):
Relevant Pages
|