Shortcuts

G

Greg Maxey

I have seen a few shortcuts for writing code from reading these groups. Here is an example with select case.

This first bit of code shows an example of how I first learned to use Select Case.

Sub Test()
Dim myString As String
myString = "Red"
Select Case myString
Case Is = "Red"
MsgBox "It's red"
Case Is = "Blue"
MsgBox "It's blue"
Case Else
MsgBox "Not recognized"
End Select
End Sub

I know now that I can shorten that to this:

Sub Test1()
Dim myString As String
myString = "Blue"
Select Case myString
Case "Red": MsgBox "It's red"
Case "Blue": MsgBox "It's blue"
Case Else: MsgBox "Not recognized"
End Select
End Sub

I only know that because I have seen examples here. Where are these little jewels like the ":" documented?

Thanks.
 
H

Helmut Weber

Hi Submariner,

IMHO, the ":" is nothing else but a chr(13) without linebreak.

Dim myString As String
myString = "Red"
Select Case myString
Case Is = "Red": MsgBox "It's red"
Case Is = "Blue": MsgBox "It's blue"
Case Else: MsgBox "Not recognized"
End Select

But what "Is" really implies, is beyond my knowledge.
There must be more to it, than hits the eye.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top