Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-23-2005, 09:58 AM   #1 (permalink)
 
Banned

Join Date: Feb 2005

Posts: 74

MBennett

Default VBscript

I have vbscript program that uses a select case statement to redirect users based on their zip code.

All other zip codes not specifically listed in the case statement are directed to the same place using "case else". Now I am trying to break down the "all others" into three categories based only on the first two digits of the zip code entered.

All other zip codes are matched by all numbers and now I need to match just the first two numbers.

This of course needs to happen after the original cases have been ruled out.


I have been trying to use:
"case Instr(04)"
but this doesn't work as the user is directed to "page not found"

Thanks in advance for any tips or advice!!!
MBennett is offline  
Old 03-23-2005, 12:41 PM   #2 (permalink)
 
Super Techie

Join Date: Mar 2005

Posts: 259

C.Ingram

Send a message via AIM to C.Ingram Send a message via Yahoo to C.Ingram
Default

try something like:
Code:
select case Zip
...
    case else:
        Dim String FirstTwo
        FirstTwo = Left(CStr(Zip), 2)
        select case FirstTwo
            case "04": 'Code...
            case "05": 'Code...
        end select
end select

__________________
Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken
C.Ingram is offline  
Old 03-23-2005, 01:05 PM   #3 (permalink)
 
Banned

Join Date: Feb 2005

Posts: 74

MBennett

Default

I have since figured out a way to get it to work.. It might be a little "messy" but this is what I have done:

case else
if sZipCode > 02999 then
'Code
end if

if sZipCode > 03999 then
'Code
end if

if sZipCode > 04999 then
'Code
end if
end select

Like it said, it might be considered a bit 'crude' and unconventional but it does the trick.

I appreciate your opinions. Let me know what you think of this idea or the possible benefite of changing it...

THANKS!!
MBennett is offline  
Old 03-23-2005, 02:58 PM   #4 (permalink)
 
Super Techie

Join Date: Mar 2005

Posts: 259

C.Ingram

Send a message via AIM to C.Ingram Send a message via Yahoo to C.Ingram
Default

Just make sure your code logic is solid. If the zip code is 50000 it will trigger all 3 If blocks.
__________________
Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken
C.Ingram is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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