Sub Main
Dim Str1 As String
Dim Str2 As New StringClass
Str1 = "Hello, world!"
Str2 = "Hello, world!"
MsgBox Str1
MsgBox Str2
End Sub
| Because StringClass was designed as a Class, the declaration of a StringClass variable differs from the declaration of a native string. See the example, shown on the left:
|
Sub Main
Dim Str1 As String
Dim Str2 As StringClass
Set Str2 = New StringClass
Str1 = "Hello, world!"
Str2 = "Hello, world!"
MsgBox Str1
MsgBox Str2
End Sub
| The New keyword is required, because a new instance of the StringClass object needs to be created. It is also possible to use the following alternative declaration for the Str2 variable from the example above. See this example:
|