-
I would like to create 2 buttons to be placed next to the other buttontoolbars at the top in Visual Basic. I have managed to create a simple Add-in, but that is only shown as a normal window. I want one button to start my webserver and another to shut it down.
Does anyone know how this is done?
-
I'm curious to know, how do you actually write an add-in for VB?
Pardon if I sounds too stupid.
Thanks!!
-
How to create an Add-in
A simple way to create an Add-in which counts the number of lines in a specific component:
Nr 1. Create a new project af the Addin-type, name the form fdmAddIn.
Nr 2. Add 3 text-fields named: txtProject, txtComponent, txtCodeLines.
Nr 3. Add some labels to each text-field to indicate what to type in each textfield. (I have 3 labels)
Nr 4. Add 2 buttons named: cmdCountCodeLines and cmdDone
Nr 5. Add the following code to the Form:
Public VBInstance As VBIDE.VBE
Public Connect As Connect
Option Explicit
Private Sub CancelButton_Click()
Connect.Hide
End Sub
Private Sub OKButton_Click()
MsgBox "AddIn operation on: " & VBInstance.FullName
End Sub
Private Sub cmdCountCodeLines_Click()
Dim strVBProject As String
Dim strVBComponent As String
Dim objVBComponent As VBComponent
strVBProject = txtProject.Text
strVBComponent = txtComponent.Text
Set objVBComponent = VBInstance.VBProjects.Item(strVBProject).VBComponents.Item(strVBComponent)
txtCodeLines.Text = Str(objVBComponent.CodeModule.CountOfLines)
End Sub
Private Sub cmdDone_Click()
Connect.Hide
End Sub
Private Sub Form_Load()
End Sub
Nr 6. Open the Connect.dsr and change the Addin Display Name to: Code Line Counter
Nr 7. Choose | File | Make CodeLineCounter.dll
Nr 8. Add the following line to vbaddin.ini which you will find in your windows-dir:
CodeLineCounter.Connect=0
Nr 9. Back into VB, choose Add-In | Add-In Manager. Select the Loaded/Unloaded and Load On Startup checkboxes; Now click OK.