Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted code execution Rick Excel Discussion (Misc queries) 2 March 26th 10 02:14 PM
Prevent users from breaking VBA code execution KerranJast Excel Programming 2 May 31st 06 04:32 PM
Code execution has been interrupted Stuart C Excel Programming 3 March 23rd 06 09:02 AM
code execution has been interrupted François Excel Discussion (Misc queries) 1 February 18th 05 11:06 PM


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"