Inputbox -Cancel button - Causes failure

Inputbox -Cancel button - Causes failure

BRLMCHKD
Advocate Advocate
1,056 Views
4 Replies
Message 1 of 5

Inputbox -Cancel button - Causes failure

BRLMCHKD
Advocate
Advocate

Hi Forum.

Could someone provide me some help to a simpel solution, to avoid failure, when cancel button is hit?

 

Thank you 🙂

KR

BRLMCHKD

0 Likes
Accepted solutions (1)
1,057 Views
4 Replies
Replies (4)
Message 2 of 5

clutsa
Collaborator
Collaborator
Accepted solution

After you cancel the input box the rest of the code continues to run. Add a line to check that your variable captured something from the input box.

If Answer=vbYes Then 
myparam = InputBox("Enter a valid Dia <=OutPipeClearanceDia", "LinerDiaMachined", "Ø")
If myparam = "" Then Exit Sub '<===Added this line
MessageBox.Show("Value=" & myparam, "The value I entered")
LinerDiaMachined=myparam
LinerMachining=True
Feature.IsActive("Extrusion4_LinerMachining")=True
iLogicVb.UpdateWhenDone=True
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 3 of 5

BRLMCHKD
Advocate
Advocate

Hi Clutsa.

 

Yes, it does just the trick that I was asking for, JUST PERFECT

I do not quite understand the 'Exit Sub',  because I thought there

should be stated a 'Sub Main () prior to this, which is not the case.

Could you provide me a simple explanation to this ? 

Thank you very much.

KR BRLMCHKD

0 Likes
Message 4 of 5

clutsa
Collaborator
Collaborator

To be honest I knew that's how I would exit a macro in VBA so I tried it and it worked. My best understanding is that iLogic is actually VBA but they have some extra code going on that allows you to omit bits and pieces and iLogic fills those bits in for you. So even though you never declare a Class or Sub it assumes them for you... but I don't know if I'm assuming that or I read it somewhere.  

My "simple explanation" is that computers have little wizards that sit inside them and cast magic spells to make everything run... but that's probably not the answer your looking for Smiley Very Happy

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 5 of 5

BRLMCHKD
Advocate
Advocate

Hi Clutsa

 

No it was not quite the answer I was looking for, but thank you for your effort 🙂

 

KR

BRLMCHKD

0 Likes