InputListBox if cancel button pressed abort.

InputListBox if cancel button pressed abort.

K.TRYFONIDIS
Advocate Advocate
820 Views
3 Replies
Message 1 of 4

InputListBox if cancel button pressed abort.

K.TRYFONIDIS
Advocate
Advocate

Hello all,

 

So i have this simple Array list that covers my needs.

 

And after this one there is another one and another one untill i populate all the properties i need.
My problem is that i want somehow to go to end of the script or abort "the mission" if the user clicks the X button ( cancel button) at the top right corner. Maybe show a message prompt like, "do you want to abort?"

Now i have to click X at all forms to end the script.

Is there a simple command like If cancel.button pressed go to [label] or go to end of script ?

 

Thanks a lot in advance.

 

Dim oValueList1 As New ArrayList
	oValueList1.Add("option1")
	oValueList1.Add("option2")
	oValueList1.Add("option3")
Dim oValue1 As String = InputListBox("Choose Material", oValueList1)

iProperties.Value("Custom", "Materialtype") = oValue1

 

0 Likes
Accepted solutions (1)
821 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Absolutely.  There are usually a few ways to handle this, depending on your needs.  Here is one example.

Dim oValueList1 As New ArrayList
oValueList1.Add("option1")
oValueList1.Add("option2")
oValueList1.Add("option3")
Dim oValue1 As String = InputListBox("Choose Material", oValueList1)
If String.IsNullOrEmpty(oValue1) Then
	If MsgBox("Do you want to abort?", vbYesNo + vbQuestion, "Abort?") = vbYes Then Exit Sub
End If
iProperties.Value("Custom", "Materialtype") = oValue1

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

WCrihfield
Mentor
Mentor

Or, if you had not pre-defined the 'oValue1' variable as a String, and since you had not really defined that Type of objects in the ArrayList, the value returned from the InputListBox would be a generic Object.  So, you could check if the un-defined variable that holds the result 'Is Nothing'.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

K.TRYFONIDIS
Advocate
Advocate

Ok this is very clever ! Thank you! 🙂

0 Likes