9.0
93
C:\ABCTemp\vbs\Dim_Definition00000109.htm
Dim
Obj As classname
Set
Obj = New classname
Can optionally contain Attributes one of which must be VB_Name.
See Also: Attribute Definition/Statement, Code Module, Object Module, Uses.
Example
'MyCommands macro
'#Uses "File.CLS"
Sub
Main
Dim
File As New File
File.Attach "C:\AUTOEXEC.BAT"
Debug
.Print File.ReadLine
End
Sub
'File.CLS class file
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute
VB_Name = "File"
Option Explicit
Dim
FN As Integer
Public
Sub Attach(FileName As String)
FN = FreeFile
Open FileName For Input
As #FN
End
Sub
Public Sub Detach()
If
FN <> 0 Then Close #FN
FN = 0
End
Sub
Public
Function ReadLine() As String
Line
Input #FN,ReadLine
End
Function
Private
Sub Class_Initialize()
Debug
.Print "Class_Initialize"
End
Sub
Private
Sub Class_Terminate()
Debug
.Print "Class_Terminate"
Detach
End Sub










