Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Shortcuts

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Maxey - 22 Jan 2006 21:50 GMT
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.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Helmut Weber - 22 Jan 2006 22:10 GMT
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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.