Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case Inclusive 1

Status
Not open for further replies.

kliz0328

Programmer
Nov 7, 2005
138
US
When writing a select case with the TO is it inclusive of both numbers
i.e. would
Case 0 To 19 include the numbers 0 and 19 or just the numbers 1-18?
 
It includes the highest number. See this code:

Code:
Option Explicit

Private Sub Form_Activate()
  Dim x As Integer, str As String
  For x = 1 To 5
    Select Case x
    Case 1 To 3
      str = str & " # " & x & vbCrLf
    End Select
  Next x
  MsgBox str
End Sub

Prints for #1,#2,and #3 only

-David
2006 Microsoft Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
You know, that's one of those things that it would just have been faster to actually try out in VB than to spend time asking here
 
At least David got his star.


Cassie
PIII-500Mhz-128MB
Win98SE-VB6SP5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top