Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Cancel InputRadioBox

tomislav.peran
Advocate

Cancel InputRadioBox

tomislav.peran
Advocate
Advocate

Hello, 

 

Does anybody know how to cancel the window that pops up if the InputRadioBox function is activated? 

 

I have a couple of nested If-functions and even if I click on "x" icon or "esc" button I still get the second window that is activated by the second InputRadioBox function. That window can not be canceled as well. 

 

Cube_size= InputRadioBox("Select the size of the cube", "10", "20",Cube_size, Title := "Size of the cube")	

If IsNothing(Cube_size) Then Exit Sub -> this does not help

Tom

0 Likes
Reply
Accepted solutions (2)
395 Views
6 Replies
Replies (6)

WCrihfield
Mentor
Mentor
Accepted solution

Hi @tomislav.peran.  Does that variable Cube_size represent a local parameter?  Has it been declared as a Boolean (Dim Cube_size As Boolean)?  Is that InputRadioBox line being used inside of a 'loop', where it might be possible for that variable to 'retain' a value from the previous run?  A Boolean Type variable can not be 'nullified', and can not be properly compared to 'Nothing'.  Even when a Boolean Type variable has just been declared, it will already have the value of False, by default.  If the variable was never declared as any Type, but is used in a loop, it may be retaining its value from the last time, and in that case, it might be possible to set it equal to Nothing before that point in the loop each time, to reset it.

I also believe there may be a way to access the dialog, if launched in a different way, but I don't think I have ever tried it before.  This 'other way' would require more lines of code, and be more complicated, but I believe it would allow you to either retain, or gain a reference to the dialog as a regular Windows Form, then use the tools available to that Type to further manipulate it, or close it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @tomislav.peran 

 

As @WCrihfield  mentioned a raidio box returns a True/False value... So as you have it written, this code is checking to see if Cube_size is 10, in which case it returns True.

 

If you select 20, you are really just saying that Cube_size is not 10.

 

So a radio box might not be the correct choice here. A List Box might be a better fit.

 

In any case, here is one method to catch the cancel button for a radio box, but it is just checking to see if the value has been changed, and if not it exits the sub.

 

 

oDefault = Cube_size
Cube_size = InputRadioBox("Select the size of the cube", "10", "20", oDefault, Title := "Size of the cube")	

If oDefault = Cube_size Then 
	'value didn't change
	Exit Sub
End If
	
MsgBox("value changed")

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

0 Likes

tomislav.peran
Advocate
Advocate

Hi WCrihfield,

 

1. Cube_size is indeed a local parameter used only inside one rule.

2. It has not been declared as a Boolean parameter. The rule works without definition.

3. "Is that InputRadioBox line being used inside of a 'loop', where it might be possible for that variable to 'retain' a value from the previous run?" -> nope. It has no value beforehand.

4. "Boolean Type variable can not be 'nullified', and can not be properly compared to 'Nothing' " -> That is the problem here. 

 

I get it now. Thanks for the explanation. 

0 Likes

tomislav.peran
Advocate
Advocate

Hi Curtis,

 

Indeed ListBox works perfectly in this case. I have tested that before but I did not understand why I can not do the same with Boolean parameters. I think that is the correct solution to this problem. 

 

Thanks for your code!

 

Dim oOptions As New List (Of String)

oOptions.Add("1.Cube 10")
oOptions.Add("2.Cube 20")
Dim oChosenOption As String = InputListBox("Choose the cube size", oOptions, "", "Cube size", "List of Options") If IsNothing(oChosenOption) Then Exit Sub

 

Thanks a lot guys,

Tom 

0 Likes

WCrihfield
Mentor
Mentor

Hi @tomislav.peran.  I'm glad we were able to help.  However, I would make one more suggestion, pertaining to your final code posted above.  Once a String type variable has been declared as a String, it will not really be Nothing afterwards.  The term Nothing is best used for comparing to variables that are to contain some sort of reference object, not textual/numerical type data.

A String type variable can be checked in the following common ways:

If oChosenOption = "" Then Exit Sub
If String.IsNullOrEmpty(oChosenOption) Then Exit Sub
If String.IsNullOrWhiteSpace(oChosenOption) Then Exit Sub

Similar idea with Double, Integer, Single, etc.  If 'empty' they will have a value of zero, not Nothing.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

tomislav.peran
Advocate
Advocate

Hi WCrihfield,

 

Nice, I will adjust that in my codes. Thanks. 

0 Likes