Hi,
I am trying to create a VB 6.0 Addin by using VB itself
I do have 2 problems here
1. How to get the current active project, active form?
Set p = VBInstance.ActiveVBProject
Set c = p.VBComponents.Item("Form1
") <- I could only hardcode this, but no idea how to dynamically get the current active project active form.
2. Whenever there is a button click, it will close the form.
==========================
==========
==========
==========
=
Public VBInstance As VBIDE.VBE
Public Connect As Connect
Option Explicit
Private Sub CancelButton_Click()
Connect.Hide
End Sub
Private Sub Command1_Click()
UpdateTag
End Sub
Private Sub Form_Load()
Dim c As VBComponent
Dim p As VBProject
Dim vbc As VBControl
Dim vbf As VBForm
Dim sc As String
Dim sp As String
Dim svbc As String
Set p = VBInstance.ActiveVBProject
Set c = p.VBComponents.Item("Form1
")
List1.Clear
If c.Type = vbext_ct_VBForm Then
c.Activate
Set vbf = c.Designer
For Each vbc In vbf.VBControls
'MsgBox vbc.Properties("name")
List1.AddItem vbc.Properties("name")
List1.ItemData(List1.NewIn
dex) = IIf(IsNumeric(vbc.Properti
es("tag"))
, vbc.Properties("tag"), 0)
Next vbc
End If
End Sub
Private Sub UpdateTag()
Dim c As VBComponent
Dim p As VBProject
Dim vbc As VBControl
Dim vbf As VBForm
Dim sc As String
Dim sp As String
Dim svbc As String
Set p = VBInstance.ActiveVBProject
Set c = p.VBComponents.Item("Form1
")
If c.Type = vbext_ct_VBForm Then
c.Activate
Set vbf = c.Designer
For Each vbc In vbf.VBControls
If vbc.Properties("name") = List1.List(List1.ListIndex
) Then
vbc.Properties("tag") = Text1.Text
Exit For
End If
Next vbc
End If
End Sub
Private Sub List1_Click()
Text1.Text = List1.ItemData(List1.ListI
ndex)
End Sub
==========================
==========
==========
==========
======
When I click on the command button1, it will execute the code inside, and auto close the frmAddIn.
May I know how can I make it remain open? (I didn't write any code to hide it of close it)
Thanks.
Start Free Trial