Private Sub Class_Initialize()
'body
End Sub
Private Sub Class_Terminate()
'body
End Sub
Class_initialize() corresponds to the FinalInitialize() in COM/ATL. It is called once, when the first reference to this component is created.
Class_terminate() corresponds to the FinalTerminate() in COM/ATL. It is called once, when the reference count goes to 0.
dim XX as AReferenceGoesHere
set XX = new AReferenceGoesHere
The 'Set' is required. Intellisense works.
if abc = 21 then
abc = 22
ElseIf abc = 22 Then
abc = 23
end if
dim i
for i = 1 to 10
'loop body
next i
Do While Not aValue
' loop body
loop
For Each Child In Children
'loop body
Next
Exit Sub
Exit Function
Sub xx
On Error GoTo ErrHandler
'sub body here
Exit Sub
ErrHandler:
'error handler code here
errNbr = Err.Number 'holds the error id
errDescr = Err.Description 'a string explaining the error
End Sub
This causes any errors to set the Err global variable and continue on.
On Error Resume Next
This causes error handling to revert to the system default (i.e. put up
a msg box.
On Error GoTo 0
UCase$("abc") ' returns "ABC"
Right$("ABC", 2) ' returns "BC"
Left$("ABC", 1) ' returns "A"
Len$("ABC") ' returns 3
Trim(" ABC ") ' returns "ABC"
Mid("ABC", 1, 1) ' returns "B"
CInt("123") ' returns an integer 123
CStr(123) ' returns a string "123"
CSng("1.23") ' returns a single (C++ => float)
Public Property Let CustomerID(RHS As String)
mLocalVrbl = RHS
End Property
Public Property Get CustomerID() As Variant
CustomerID = mLocalVrbl
End Property
private sub XX(ByVal theIndex As String, ByRef theValue As String)
All parameters are passed by reference. The ByVal is default
and is not required.
ByVal indicates that the reference is is a constant, e.g. it is an [in] parameter. The value contained in theIndex is not constant, it can be changed. However Strings are immutable and so the caller sees no changes. If theIndex was an object, it can be changed by XX.
ByRef indicates that it is an [out] parameter. The reference can be changed. If theValue points to a new string, the caller sees the change.
Dim fs As Scripting.FileSystemObject
Set fs = New Scripting.FileSystemObject
If Not fs.FolderExists(sBuildPath) Then
fs.CreateFolder (sBuildPath & "\")
endif
Dim aFlatFile As Scripting.TextStream
Set aFlatFile = fs.CreateTextFile(sFileName, True)
aFlatFile.WriteLine ("abc" & Chr(9) & "def")
aFlatFile.Close
MsgBox mAvariable