|
-
Aug 6th, 2000, 09:26 PM
#1
Thread Starter
Hyperactive Member
This ones probably so easy that you'll all cringe and think that i'm stupid. But being a learner of Javascript, it has to be asked.
In VB there is the Select Case statement, and i think in C there is the Switch statement, which is a whole lot quicker than a heap of if then else statements.
Now on to my question, is there anything similar in VB?
Or do i have to resort to a whole lot of if/then statements. And with what i have in mind its gonna be a WHOLE lot of if then statements.
Cheers people.
BW
-
Aug 6th, 2000, 10:48 PM
#2
Member
If you mean VBScript then it has the same syntax as ol'
VB - Select Case. I'm not an expert on VBScript and I
haven't done anything in it but i'm pretty sure that
that' the way it is.
Mel.
-
Aug 6th, 2000, 10:51 PM
#3
Thread Starter
Hyperactive Member
nah i meant javascript
but i think i have it sorted out now, so thats cool
Cheers for the info Mel.
BW
-
Aug 8th, 2000, 06:40 PM
#4
Thread Starter
Hyperactive Member
Nop i was wrong
I don't have it sorted. Anyone out there that can help me?
BW
-
Aug 8th, 2000, 06:51 PM
#5
Hyperactive Member
Code:
<Script Language = "JavaScript">
var x = 7;
switch(x) {
case 1:
alert("nope");
case 3:
alert("still not it");
case 7:
alert("thats the one");
}
</Script>
[Edited by noone on 08-08-2000 at 11:51 PM]
"People who think they know everything are a great annoyance to those of us who do."
-
Aug 8th, 2000, 06:56 PM
#6
Thread Starter
Hyperactive Member
Thanks to Noone
Cheers for that.
I had almost given up hope.
BW
-
Aug 8th, 2000, 07:10 PM
#7
Thread Starter
Hyperactive Member
one last note
is there an else part for switch?
eg
switch(x)
{
case 1:
...
case 2:
...
case else:
...
}
to catch it if its not one of the previous options?
BW 
PS also does it work for strings not only numbers? I have one working with a string and it seems to go through all the options.
[Edited by But_Why on 08-08-2000 at 08:15 PM]
-
Aug 8th, 2000, 07:27 PM
#8
Hyperactive Member
There shoudlnt be any reason strings wouldnt work.
this is a better example, I forgot the break statements in the other one:
Code:
<Script Language = "JavaScript">
var x = 7;
switch(x) {
case 1:
alert("nope");
break;
case 3:
alert("still not it");
break;
case 9:
alert("thats the one");
break;
default:
alert("none of them");
}
</Script>
[Edited by noone on 08-08-2000 at 11:52 PM]
"People who think they know everything are a great annoyance to those of us who do."
-
Aug 8th, 2000, 07:33 PM
#9
Thread Starter
Hyperactive Member
Excellent
With Default and break on my side i now have it going properly. Thanks heaps Noone.
BW
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|