Solved

Case Stament to compare numbers

Posted on 2009-06-29
7
185 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 143

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 143

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

789 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