Excel VBA Colon

Possible duplicate:
VB Use colons to place two statements on the same line

I have the following declaration in Excel VBA

Public Const cdbArea = 1: Public Const cdbDist = 2: Public Const cdbChange1 = 4: Public Const cdbChange2 = 5: Public Const cdbTR = 5:
Public Const crbArea = 1: Public Const crbDist = 2: Public Const crbTerr = 3: Public Const crbChange1 = 4: Public Const crbTR = 5:
Public Const cdbWeek1 = 4

At first glance, Colons look like delimiters, but I have never used this syntax before.

What are the Colons for?

+5
source share
3 answers

You can put instructions on separate lines if you want:

Public Const cdbArea = 1
Public Const cdbDist = 2
Public Const cdbChange1 = 4

Or you can separate them by a colon, as in the example above.

+8
source

Another use of the colon is to set certain variables in the calling statement:

Option Explicit

Sub test()
    testWithOptions thirdParameter:="SecondParameterSkipped", firstParameter:="firstParam"
End Sub

Sub testWithOptions(firstParameter As String, Optional secondParameter As String, Optional thirdParameter As String)
    MsgBox "FirstParamter:  " & firstParameter & vbCrLf & _
                "ThirdParamter:  " & thirdParameter
End Sub

, , ( ) .

.

+3

, , BoltBait. , , , .

^^

+2

All Articles