• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Is there a better way ?

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
AnitaP
Asked:
AnitaP
  • 3
1 Solution
 
jcondeCommented:
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
 
AnitaPAuthor Commented:
How about Visual Basic 4 ?

I am using this code in an ASP script which is mostly formed of Visual Basic code.
0
 
mrgentryCommented:
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
 
AnitaPAuthor Commented:
Thank you.
0
 
AnitaPAuthor Commented:
by the way, it is SELECT case and not SWITCH
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now