Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm and .hide: prevent code from further execution
Hi,
I can show a Userform by "SampleUserForm.Show" and make it dissapear by "SampleUserForm.hide" So far, so good. I created code which might produce a division by zero, depending on former input. My code (simplified UserForm): Private Sub Calculation If a <= 0 Then Calculation.Hide ' Just this UserForm should "hide"/disappear and code in just this Userform should stop End If b = Log (a) ' This leads to an error (division by zero) if a <= 0 End Sub So ".Hide" makes the UserForm disappear but keeps the code running. Otherwise "Stop" (or is it "Halt"?) would make the whole program stop. I'm searching for a possibility to hide the UserForm and prevent the code in this UserForm from going on. Thanx for any suggestions, - Christian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm and .hide: prevent code from further execution
Hi Christian,
Try something like: '============= Private Sub CommandButton1_Click() Dim a As Double Dim b As Double If a <= 0 Then Unload Me Exit Sub End If b = Log(a) End Sub '<<============ --- Regards, Norman "Christian" wrote in message oups.com... Hi, I can show a Userform by "SampleUserForm.Show" and make it dissapear by "SampleUserForm.hide" So far, so good. I created code which might produce a division by zero, depending on former input. My code (simplified UserForm): Private Sub Calculation If a <= 0 Then Calculation.Hide ' Just this UserForm should "hide"/disappear and code in just this Userform should stop End If b = Log (a) ' This leads to an error (division by zero) if a <= 0 End Sub So ".Hide" makes the UserForm disappear but keeps the code running. Otherwise "Stop" (or is it "Halt"?) would make the whole program stop. I'm searching for a possibility to hide the UserForm and prevent the code in this UserForm from going on. Thanx for any suggestions, - Christian |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm and .hide: prevent code from further execution
On 10 Mai, 12:19, "Norman Jones"
wrote: Hi Christian, Try something like: '============= Private Sub CommandButton1_Click() Dim a As Double Dim b As Double If a <= 0 Then Unload Me Exit Sub End If b = Log(a) End Sub '<<============ --- Regards, Norman "Christian" wrote in message oups.com... Hi, I can show a Userform by "SampleUserForm.Show" and make it dissapear by "SampleUserForm.hide" So far, so good. I created code which might produce a division by zero, depending on former input. My code (simplified UserForm): Private Sub Calculation If a <= 0 Then Calculation.Hide ' Just this UserForm should "hide"/disappear and code in just this Userform should stop End If b = Log (a) ' This leads to an error (division by zero) if a <= 0 End Sub So ".Hide" makes the UserForm disappear but keeps the code running. Otherwise "Stop" (or is it "Halt"?) would make the whole program stop. I'm searching for a possibility to hide the UserForm and prevent the code in this UserForm from going on. Thanx for any suggestions, - Christian Thank you very much, that's it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unwanted code execution | Excel Discussion (Misc queries) | |||
Prevent users from breaking VBA code execution | Excel Programming | |||
Code execution has been interrupted | Excel Programming | |||
code execution has been interrupted | Excel Discussion (Misc queries) |