Solved

Case Stament to compare numbers

Posted on 2009-06-29
7
159 Views
Last Modified: 2012-05-07
I need to have a case statement to compare a variable and see if it is between two numbers.

i.e

Select Case PageCount

case (between 0 an 100
 postage = 1.10
case (between 101 and 200)
 Postage = 2.20
case else
 postage 5.50

end select

How do I accomplish this
0
Comment
Question by:BPWALKIN
  • 3
  • 2
  • 2
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24739489
this should do
Select Case PageCount 
case is => 0 and is <= 100
 postage = 1.10
case is > 100 and is <= 200
 Postage = 2.20
case else
 postage 5.50 
end select

Open in new window

0
 

Author Comment

by:BPWALKIN
ID: 24739509
I am using VB6 I am getting a syntax error with that code.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24739581
where exactly, and which error?

alternative:
Select Case 

case PageCount => 0 and PageCount <= 100

 postage = 1.10

case PageCount > 100 and PageCount <= 200

 Postage = 2.20

case else

 postage 5.50 

end select

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24739741
How about?
        Select Case PageCount

            Case 0 To 100

                postage = 1.10
 

            Case 101 To 200

                postage = 2.20
 

            Case Else

                postage = 5.50
 

        End Select

Open in new window

0
 

Author Comment

by:BPWALKIN
ID: 24739764
regardless of the value in pagecount I am getting 5.5 in my postage value.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24739781
Who was that directed at?...and is PageCount a NUMERIC variable or a STRING?
0
 

Author Comment

by:BPWALKIN
ID: 24739787
Numeric , last message was posted to angell
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

23 Experts available now in Live!

Get 1:1 Help Now