Tuesday, June 12, 2012

Di manakakah letak procedure Sub Main? - VB6 Add-Ins

Karena letak prosedure Sub Main() bisa di module mana saja, maka untuk mengetahuinya melalui project VB6 Addin, maka kita memerlukan kode di bawah ini:
Private Function GetSubMain() As String 
Dim v As
VBComponent
Dim l As Long, s As String
For Each v In
VBInstance.ActiveVBProject.VBComponents
With v
If
.Type = vbext_ct_StdModule Then
l =
v.CodeModule.CountOfLines
If l > 0 Then
s =
v.CodeModule.Lines(1, l)
If InStr(1, s, "sub main()", vbTextCompare) > 0 Then
GetSubMain = v.Name
Exit Function
End If
End If
End If
End With
Next
End Function