• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

terminate executing code

dear sir,

how to stop execute the executing code ?for example, consider the following code. if l ran this code, it would go to test function, now l would like to write a code in test function to stop executing. make sure it won't turn back to msgbox line.but not end the whole program, just to terminate executing the form1 only. how to do it ? if l write with unload function, it would be back to msgbox line.

private sub form_load()
test
msgbox "Test"
end sub

private sub test()
'some code here to stop executing
end sub
0
e_aks
Asked:
e_aks
  • 3
  • 2
1 Solution
 
Anita030598Commented:
What's that you are trying to do? Somewhere it will come back.
However you can avoid executing the rest of the lines in Form_Load after test by setting a flag in test. Do it this way:

Dim bFlag As Boolean

private sub form_load()
test
if Not bFlag Then
   msgbox "Test"
end if
end sub

private sub test()
'some code here to stop executing
 bFlag = True
end sub
0
 
Anita030598Commented:
you can add Unload Me after bFlag = True in test sub if you want the form to be not loaded as well.
0
 
e_aksAuthor Commented:
thanks, but is  this just only way to do it ?
0
 
Anita030598Commented:
As far as I know this is one best and simple way to do.
0
 
e_aksAuthor Commented:
ok thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now