Solved

Is there a better way ?

Posted on 1999-01-14
5
187 Views
Last Modified: 2013-12-25
Is there a better way to do this ?

PrixMax=0
IF iprix = 1 Then
      PrixMax = 2000
Else
      If iprix = 2001 THEN
            PrixMax = 5000
      ELSE
            If iprix = 5001 THEN
                  PrixMax = 10000
            ELSE
                  IF iprix = 10001 THEN
                        PrixMax = 14000
                  ELSE
                        IF iprix = 14001 THEN
                              PrixMax = 20000
                        END IF
                  END IF
            END IF
      END IF
End IF

besides assigning a variable to each of the values ?
0
Comment
Question by:AnitaP
  • 3
5 Comments
 
LVL 7

Expert Comment

by:jconde
Comment Utility
Hi, I really don't know basic that much, but in C or Pascal you could do something like:

case iprix of      //PASCAL
  1: PrixMax := 2000;
  2001: PrixMax := 5000;
  5001: PrixMax := 10000;
10001: PrixMax := 14000;
14001: PrixMax := 20000;
end;


switch (iprix) {      /*C / C++*/
  case 1: PrixMax = 2000;
  case 2001: PrixMax = 5000;
                   break;
  case 5001: PrixMax = 10000;
                   break;
  case 10001: PrixMax = 14000;
                   break;
  case 14001: PrixMax = 20000;
                   break;
}

Hope it helps!!

Regards,

Jorge del Conde
0
 

Author Comment

by:AnitaP
Comment Utility
How about Visual Basic 4 ?

I am using this code in an ASP script which is mostly formed of Visual Basic code.
0
 
LVL 1

Accepted Solution

by:
mrgentry earned 10 total points
Comment Utility
I believe this is how it's done in VB.

PrixMax = 0
Switch Case iprix
    Case 2001
        PrixMax = 5000
    Case 5001
        PrixMax = 10000
    Case 10001
        PrixMax = 14000
    Case 14001
        PrixMax = 20000
End Select

0
 

Author Comment

by:AnitaP
Comment Utility
Thank you.
0
 

Author Comment

by:AnitaP
Comment Utility
by the way, it is SELECT case and not SWITCH
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now