Hi @projeto1LKKGD. That is a tough one. For starters, when using regular iLogic Forms, you can choose to show the form as 'Modal', or not. If shown Modal, the code that launched it will be paused while that form remains open, and this allows you to capture how the form was closed, and to be able to react to the forms closure. Below is an expanded version of your original code above.
Sub Main ()
oQ=MessageBox.Show("Queres verificar se os dados de legenda estão corretos?", "Atenção",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If oQ = DialogResult.Yes Then
'to do something after the form closes, show it as Modal, then capture its return value
Dim oFRV As FormReturnValue = iLogicForm.Show("DADOS LEGENDA", FormMode.Modal)
'now you can check the return value to check how it was closed, and react to its closure
If oFRV.Result = FormResult.Done Then
Logger.Info("You clicked the 'Done' button on your 'DADOS LEGENDA' form.")
ElseIf oFRV.Result = FormResult.OK Then
Logger.Info("You clicked the 'OK' button on your 'DADOS LEGENDA' form.")
End If
End If
End Sub
However, if you want to be able to cancel saving or cancel closing a document, you will need to use almost completely different, and more complex code solution. When using the Event Triggers dialog box to run iLogic rules, you do not have any control over that event, so you can not prevent that event from continuing to do its task after your rule runs. You would have to use actual custom event handler code, which has direct access to that real Event itself, to have that level of control. I have attached a PDF of one of my old contribution posts about working with event handlers in vb.net / iLogic. The documentation needs to be updated, but has some good information. Within the event handler block of code, you have access to the timing of before or after the event (Link), and a tool (Link) that can be used to cancel the event.
Wesley Crihfield

(Not an Autodesk Employee)