0
votes

I have this VB Code used in an Invoke Code Activity in UiPath. Can anyone suggest a function which changes the values of variable btnClicked in True when the button is pressed?

Dim lblButton As New System.Windows.Forms.Button()
lblButton.AutoSize = True
   btnClicked=False
            lblButton.ForeColor = System.Drawing.Color.Black
            'lblButton.Location = New System.Drawing.Point(5, 10)
   lblButton.Left=250
            lblButton.Name = "lblButton"
            lblButton.Size = New System.Drawing.Size(50, 50)
            lblButton.TabIndex = 4
            lblButton.Text = "End data acq"
   lblbutton.Visible=btnVisible

   btnClicked=True
1
What exactly are you trying to achieve? Should the robot wait for a user to provide feedback before fetching data? Have you considered using a UiPath.Core.Activities.InputDialog? - Wolfgang Radl
Yes,but I have a VB form and I need to create this function for the button in this form. - Alexa Sorina
Please provide some context. It appears that you want to check if a user acknowledged something at a certain point (e.g. data acquisition completed), but those are just assumptions. if that's the case however, a simple message box with Yes/No could achieve the same thing w/o the need for Invoke Code. - Wolfgang Radl
Yes,I need the button for the user can stop the data acquisition,and when the button is clicked by the human user, I need to receive from Invoke Code an argument which gives me the value True or False. I cannot use the Message Box because my button for stoping the process is in this VB form made in the invoke code activity - Alexa Sorina
Is your VB Code responsible for data acquisition as well (i.e. fetching data in a separate thread)? (Wouldn't anything else block the whole process?) - Wolfgang Radl

1 Answers

0
votes

I think all you need is to add a handler to the OnClick event. In Windows.Forms.Buttons this fires when the user clicks each time. I don't have any experience with rpa or uipath, so my apollogies if this is not a full answer.

Private Sub My_Clicked_Event(sender As Object, e As EventArgs)
    Dim lb As System.Windows.Forms.Button = DirectCast(sender, System.Windows.Forms.Button)
    lb.Text = "I have been clicked"
    lb.Forecolor = Color.Black
    MsgBox("Clicked")
End Sub

then add the handler in your code

AddHandler lblbutton.Click, AddressOf My_Clicked_Event

Changing variables could simply be done using the casted lb...