RobotStudio event

read output in VBA

I want to read an output from the active robotcontroller in my vba application in an IF THEN but it won't work.

 

Regards

 

Michael

Michael Sander Jensen

Comments

  • Hi Michael

    Here comes 2 different examples how you could do it.

    The first one is just a simple read of IO from controller and

    the second one reacts on changes on a specific IO.

    1.

    Sub ReadIO()
        Dim mIO As IO
       
        Set mIO = ActiveStation.ActiveMechanism.Controller.IO("doFinish")
       
        If mIO.Value = 1 Then
            MsgBox "Value is 1"
        Else
            MsgBox "Value is 0"
        End If
       
    End Sub

    2.

    Dim WithEvents mIO As IO

    Sub ConnectIO()
        'Run this to start looking for changes
        Set mIO = ActiveStation.ActiveMechanism.Controller.IO("doFinish")
    End Sub

    Private Sub mIO_Change()
        'This will execute if there is a value change
        If mIO.Value = 1 Then
            MsgBox "Value is 1"
        Else
            MsgBox "Value is 0"
        End If
    End Sub

    Hope this will help you

    Regards

    Per

    Per Svensson
    Company Specialist
    ABB Automation Technology Products