RE: VBScript If/ElseIf Processing
by "David Clapper" <dclapper(at)clioassociates.com>
|
Date: |
Tue, 13 Mar 2001 11:59:04 -0800 |
To: |
WebMaster(at)bastyr.edu |
Cc: |
hwg-techniques(at)hwg.org |
|
todo: View
Thread,
Original
|
|
Hi Doug,
I believe it will look at all the ELSEIFs until it hits a valid
one.
Probably a better way to do this (not sure if it's more efficient,
but it's definitely cleaner) is to use the SELECT CASE statement.
Documentation and example at
http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/vsstmSelectCase.htm
>--- Original Message ---
>From: "Bastyr University WebMaster" <WebMaster(at)bastyr.edu>
>To: <hwg-techniques(at)hwg.org>
>Date: 3/13/01 1:45:58 PM
>
>Hello all,
>
>Say I have a vbscript that goes something like:
>
>If i = 1 Then
> Misc code set 1
>Elseif i = 2 Then
> Misc code set 2
>Elseif i = 3 Then
> Misc code set 3
>End If
>
>where Misc code set # is various other vbscript code. Now let's
say i =
>2.
>
>My question is, will the server go through and look at the 'Misc
code set'
>code for each item? It seems that on occasion I've seen that
if there is
>a problem with say Misc code set 1, I'll get an error even though
that
>if/then was not true. If it does go through and look at every
single line
>of code (used or not), this seems rather inefficient. Is there
some way
>of making this kind of coding more efficient so it steps through
these
>quicker and/or ignores unused code?
>
>It may not work this way at all, but thought I'd ask to see
if anyone else
>could shed some light.
>
>Thanks,
>
>Doug Dossett
>Webmaster
>Bastyr University
>http://www.bastyr.edu
>
>
>
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA