Make this rule so that if the user hits cancel it makes them start over?

Make this rule so that if the user hits cancel it makes them start over?

bbrumfield
Advocate Advocate
352 Views
3 Replies
Message 1 of 4

Make this rule so that if the user hits cancel it makes them start over?

bbrumfield
Advocate
Advocate

I have rule to create a machine run time which did work well with one exception if your were to hit cancel on the inputbox you get an error :

Error in rule: Stock Sheet Metal Selection List - Test4, in document: CadTalk_Test_3.ipt

Conversion from string "" to type 'Double' is not valid.

I have tried multiple combinations with no success most ending in an endless loop.

 

The Value for machine run time can't be 0 or nothing 

A positive value lets you move on,  and cancel can't let you skip to the next rule.

 

iProperties.Value("Custom", "Operation" & Space(1) & (oOperation) & Space(1) & "Run Time" & Space(1) & (oOperation)) = CObj(InputBox("Enter Machine Run Time" & Space(1) & "(Enter 0 if no value is available)", "Run Time", 0))

If iProperties.Value("Custom", "Operation" & Space(1) & (oOperation) & Space(1) & "Run Time" & Space(1) & (oOperation)) = 0 Or Nothing Then
	MessageBox.Show("ENTER RUN TIME VALUE", "A VALUE IN THIS FIELD IS REQUIRED", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
	GoTo MachineRunTime
End If

 

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

JelteDeJong
Mentor
Mentor

try it like this:

Dim newValue As String = String.Empty

While (String.IsNullOrEmpty(newValue)) 

    newValue = InputBox("Enter Machine Run Time" & Space(1) & "(Enter 0 if no value is available)", "Run Time", 0)

End While

iProperties.Value("Custom", "Operation" & Space(1) & (oOperation) & Space(1) & "Run Time" & Space(1) & (oOperation)) = newValue

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @bbrumfield,

 

Your input message states that the user can enter 0, but in your question you state that you do not want to allow a value of zero. If the later is true, then I might set the default to 1, and use something like this.

 

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

 

Try 
	oCurrentValue = iProperties.Value("Custom", "Operation" & Space(1) & _
		(oOperation) & Space(1) & "Run Time" & Space(1) & (oOperation))
Catch 
	If oCurrentValue = "" Then oCurrentValue = 1 
End Try 

MachineRunTime :

oInput = CObj(InputBox("Enter Machine Run Time" & Space(1) _
	& "(Enter a value of 1 or more)", "Run Time", oCurrentValue))

If oInput = Nothing Then GoTo MachineRunTime
If oInput < 1 Then GoTo MachineRunTime

iProperties.Value("Custom", "Operation" & Space(1) & _
	(oOperation) & Space(1) & "Run Time" & Space(1) & (oOperation)) = oInput

 

EESignature

Message 4 of 4

bbrumfield
Advocate
Advocate

Hi Curtis,

 

Thank you! That rule solved the issue. The only thing I had to do was change 1 to 0.017, we log machine time in seconds. Interestingly the rule retains the current  value if run again.

 

Thanks,

 

Brent

0 Likes