RobotStudio event

Addin for RS 5.x (VB) problem

Options

Since our add-ins for RS 3.2 were written by VB, we plan to use VB.net as the developement tool. I wrote some codes to imitate the C# code. However, I do not see any add-in in RS 5.0. It would be greatly appreciated if anyone could help me fix the bug. 

 
Imports System
Imports ABB.Robotics.RobotStudio
Imports ABB.Robotics.RobotStudio.Environment
Imports ABB.Robotics.RobotStudio.Stations
Imports System.Windows.Forms


Namespace MyAddinVB

    Public Class MyAddinVB
        '''<summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
       Public Sub New()

        End Sub
        '*********************************************************** *
        ' This method is called when RS starts
       Public Sub AddinMain()

            ' Create a new command button
           Dim Buttonfiltered= New CommandBarButton("HelloMyAddinVB", "Hello MyAddin VB!")

            ' Add the button to the "Tools" menu
           ' The IDs of predefined menus and commands are found in "RobotStudioIDSummary.html"

            '
           CommandBarPopup.FromID("MenuTools").Controls.Add(Butto n)


           ' Connect the command events

            ' C# Code
           'Button.UpdateCommandUI += New UpdateCommandUIEventHandler(button_UpdateCommandUI)
           'Button.ExecuteCommand += New ExecuteCommandEventHandler(button_ExecuteCommand)

            'VB Code
           AddHandler Button.UpdateCommandUI, AddressOf button_UpdateCommandUI
           AddHandler Button.ExecuteCommand, AddressOf button_ExecuteCommand


       End Sub

        Public Sub button_UpdateCommandUI(ByVal sender As Object, ByVal e As UpdateCommandUIEventArgs)
            '  // Enable the button
           e.Enabled = True
       End Sub

 
        Public Sub button_ExecuteCommand(ByVal sender As Object, ByVal e As ExecuteCommandEventArgs)
            '    // Do something
           MessageBox.Show("Hello MyAddin VB!")
       End Sub


        '*********************************************************** ****************
   End Class


End Namespace

Comments

  • I got it.

     

    Imports System
    Imports ABB.Robotics.RobotStudio
    Imports ABB.Robotics.RobotStudio.Environment
    Imports ABB.Robotics.RobotStudio.Stations
    Imports System.Windows.Forms
    Namespace MyAddin
        Public Class MyAddin
            Public Shared Sub AddinMain()
                 Dim button As CommandBarButton = New CommandBarButton("HelloMyAddinVB", "Hello MyAddinVB!")
                 CommandBarPopup.FromID("MenuTools").Controls.Add(button)
                 AddHandler button.UpdateCommandUI, AddressOf button_UpdateCommandUI
                 AddHandler button.ExecuteCommand, AddressOf button_ExecuteCommand
            End Sub
            Shared Sub button_UpdateCommandUI(ByVal sender As Object, ByVal e As UpdateCommandUIEventArgs)
                 e.Enabled = True
            End Sub
            Shared Sub button_ExecuteCommand(ByVal sender As Object, ByVal e As ExecuteCommandEventArgs)
                 MessageBox.Show("Hello MyAddinVB!")
            End Sub
        End Class
    End Namespace