creating efficient code...advice?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there

I have a series of conditions
language = englis
language = frenc

area= wes
area = atlanti
area = quebe
area = ontari

If a user selects english and an area, then the form will open using the english captions. If they choose french and an area, then the form will open using the french captions. There are two options for each area. I was going to do a series of if statements to capture each combination of choices. Is there a better way

Many thanks in advanc

Carlee
 
The choice of language is independant of the area chosen, right? If that's the case, then your langauge choice could be handled with a single If statement

If language=english The

' Captions in englis

Els

' Captions in Frenc

End I

If you intend to add more languages in the future, you might want to convert that to a "Select Case" statement, like you should for your area

Select Case UCase(area

Case "WEST

' Area is wes

Case "ATLANTIC

' Area is atlanti

Case "QUEBEC

' Area is quebe

Case "ONTARIO

' Area is ontari

Case Els

' Optional - for any area that doesn't fit the above option

End Selec

Doing it this way makes it easier if you want to add more areas later

HT
End Selec

----- Carlee wrote: ----

Hi there

I have a series of conditions
language = englis
language = frenc

area= wes
area = atlanti
area = quebe
area = ontari

If a user selects english and an area, then the form will open using the english captions. If they choose french and an area, then the form will open using the french captions. There are two options for each area. I was going to do a series of if statements to capture each combination of choices. Is there a better way

Many thanks in advanc

Carlee
 
thanks for the help. I used the first option because the default is english. Much appreciate your time
 
Hi Carlee,

Surely the simplest thing is to handle each choice separately:

Pseudocode:
Select Case ChosenLanguage
Case English
SetEnglishCaptions
Case French
SetFrenchCaptions
End Select
Select Case Area
Case West
Do something
Case Atlantic
Do something else
...


Hi there,

I have a series of conditions :
language = english
language = french

area= west
area = atlantic
area = quebec
area = ontario

If a user selects english and an area, then the form will open
using the english captions. If they choose french and an area, then the
form will open using the french captions. There are two options for
each area. I was going to do a series of if statements to capture each
combination of choices. Is there a better way?
 
Back
Top