Tuesday, June 12, 2012

Contoh Kode Menghilangkan Item VBComponent - VB6 Add-Ins

Berikut merupakan contoh kode untuk menghilangkan salah satu VBComponent (Form, Module, UserControl, Class, dll) berdasarkan namanya:
Public VBInstance As VBIDE.VBE 
Public Connect As Connect

Option Explicit

Private Sub
CancelButton_Click()
Connect.Hide
End Sub

Private Sub
OKButton_Click()
RemoveVBComponent "Form1"
End Sub

Private Sub
RemoveVBComponent(s As String)
Dim f As VBComponent
Set f = VBInstance.ActiveVBProject.VBComponents.Item("Form1")
VBInstance.ActiveVBProject.VBComponents.Remove f
End Sub