Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to use "value description" rather than value to evaluate.

Posted on 2004-04-30
12
Medium Priority
?
155 Views
Last Modified: 2010-05-02
hi experts,
I didn't know the right terminology, sorry.
I saw this somewhere but now I can't remember.
To make the code more readable, what I'm want to do is:

Instead of:
   If a = 1 then ...
   If a = 2 then ...
   If a = 3 then ...

I'd like to say:
   If a_is_1 then ...
   If a_is_2 then ...
   If a_is_3 then ...

where (This syntax is what I'm looking for):
   dim   a    as  integer
        a_is_1 value 1
        a_is_2 value 2
        a_is_3 value 3

Thank you,
Phil
0
Comment
Question by:spoowiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:prasitlee
ID: 10965105
Hi spoowiz,
   I don't understand. Please explain more details.
                                                         Meng
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10965177
I understand what you are saying, but what you need to understand is that visual basic doesnt know what to evaluate agaisnt what when you do it like that.

You could do...

select case A
 case 1
  msgbox "A is 1"
 case 2
  msgbox "A is 2"
 case 3
  msgbox "A is 3"
end select

0
 

Author Comment

by:spoowiz
ID: 10965179
sorry. that's the best explanation i can give.
I know that if you know the syntax, you'll understand.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:spoowiz
ID: 10965185
Brian,
That's still not it. Maybe I'm just mistaken but I could swear I saw it before. (For those old fogies out there, it's an old COBOL 88 syntax which makes code very readable).
Phil
0
 

Author Comment

by:spoowiz
ID: 10965197
When reading code, it's much easier to read if it said,
   If ACCOUNT_IS_DELINQUENT THEN ....
rather than
   If AccountStatus = 7 then ... ' or whatever value

In Cobol, if I remember correctly it would be defined:
01   AccountStatus       Pic  9(2).
88   ACCOUNT_IS_DELINQUENT   VALUE 7.


0
 
LVL 6

Expert Comment

by:prasitlee
ID: 10965201
Hi spoowiz,
   May I ask you something ?

   If a_is_1 then ...
   If a_is_2 then ...
   If a_is_3 then ...
   What is a_is_1 stored ? At the line below, you told that it stored "1". If so, what if compare with so it know what it should do next. Normally if would compare and return to TRUE or FALSE. So it would know what to do next.
                                                   Meng
0
 
LVL 6

Expert Comment

by:prasitlee
ID: 10965213
Sorry to ask you again
   If ACCOUNT_IS_DELINQUENT THEN ....
   Is ACCOUNT_IS_DELINQUENT a variable or constant ?
   how could if statement know that it would be true if it is equal to 7 or any value ?
                                                                    Meng
0
 

Author Comment

by:spoowiz
ID: 10965223
Hi Meng,
That's the question. I know I've seen it somewhere, rarely used, but a very good programming technique as in the Account_is_delinquent example.
Phil
0
 
LVL 19

Accepted Solution

by:
BrianGEFF719 earned 150 total points
ID: 10965599
What you want to do is something like this:

a_is_1 when a = 1
a_is_2 when a = 2
a_is_3 when a = 3

a = 2

if a_is_2 then
 ok....
end if

this cannot be done in VB.

-Brian
0
 
LVL 1

Assisted Solution

by:sadcock
sadcock earned 150 total points
ID: 10965743
Spoowiz-

The closest you can come to the good old COBOL 88's (yes I coded them too) is a VB Boolean variable.  You would have to set the three booleans you want to interpret with if/case logic (which may defeat your purpose).  See below

Dim a_is_1 as boolean
Dim  a_is_2 as boolean
Dim a_is_3 as boolean
Select case a
   case is 1
      a_is_1 = True
   case is 2
      a_is_2 = True
   case is 3
      a_is_3 = True
end select

if a_is_1 then
   ...
end if

0
 

Author Comment

by:spoowiz
ID: 10965956
wow. another Cobol coder!
sadcock :-),
that's not it. i'm going to keep this open a bit and look for it myself so i can post it when i find it. actually, i think it was used in a module and i couldn't understand how it was done exactly. when i find it, i'll post and ask some questions.
phil
0
 

Author Comment

by:spoowiz
ID: 11095305
thanks for trying. i couldn't find it so i'm closing it.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

715 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