473,668 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stop a procedure

142 New Member
In excel VBA.
For example,
Expand|Select|Wrap|Line Numbers
  1. If cells(i,1)=1 Then
  2.   Call Procedure1
  3.   Call Procedure2
  4. End If
  5. If ....
  6.   ...
  7. End If
  8. Loop
The Procedure1 and 2 will execute every loop, but I only want the Procedure1 excutes once, and the procedure2 excutes everyloop. How can I do that?
thanks
Apr 30 '07 #1
4 1307
Killer42
8,435 Recognized Expert Expert
Probably the simplest way is to create a variable which you use to "flag" the fact procedure 1 has been run. Each time 'round the loop, if the flag hasn't been set, then run procedure 1 and set the flag.
Apr 30 '07 #2
joemo2003
142 New Member
Probably the simplest way is to create a variable which you use to "flag" the fact procedure 1 has been run. Each time 'round the loop, if the flag hasn't been set, then run procedure 1 and set the flag.
what is flag? I try to figure out "Flag" a long time ago, but still can't.
May 1 '07 #3
Killer42
8,435 Recognized Expert Expert
what is flag? I try to figure out "Flag" a long time ago, but still can't.
The term "flag" just refers to a variable that you use to indicate a particular situation. In this case, a boolean variable that you would set to True to indicate that you have performed the thing you only want to do once.

Here's some pseudo-code showing a general example (based on your situation) of the way a flag might be used...
Expand|Select|Wrap|Line Numbers
  1. Clear flag (set to False)
  2. Start loop
  3.   If Flag is not set Then
  4.     Do Proc1
  5.     Set flag (set value to True)
  6.   End If
  7.   Do Proc2
  8. End Loop
May 1 '07 #4
joemo2003
142 New Member
The term "flag" just refers to a variable that you use to indicate a particular situation. In this case, a boolean variable that you would set to True to indicate that you have performed the thing you only want to do once.

Here's some pseudo-code showing a general example (based on your situation) of the way a flag might be used...
Expand|Select|Wrap|Line Numbers
  1. Clear flag (set to False)
  2. Start loop
  3.   If Flag is not set Then
  4.     Do Proc1
  5.     Set flag (set value to True)
  6.   End If
  7.   Do Proc2
  8. End Loop
great, thanks
May 1 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7208
by: Simon Niederberger | last post by:
Hi I've written a Windows Service which has - several (0-100) listeners threads which spawn worker threads based on events, timers etc - several (0-300) worker threads which handle data (message based) and terminate after processing I'm wondering what exactly happens when I stop the service. I don't see an ThreadAbortedException, but I'm worried my worker threads might be
5
27312
by: Paul O. Morris | last post by:
Is there a script that I can run to stop a particular SQL server service on Win2003 server? I'm looking for a similar script to restart that service as well. Thanks.
16
12652
by: deko | last post by:
I have a sub routine that searches the Outlook PST for a message sent to/from a particular email address. Obviously, this can take a long time when the PST contains thousands of messages. I'd like to put a button on my Access 20003 form that will stop the sub routine when clicked. I know I can press Ctl + Break and stop the code, but is there a more graceful way to do this programmatically? Should I use SendKeys? Also, it would be...
2
1969
by: Gustavo\ | last post by:
Hi, I have a combo box in a form. It has limit to list set to "yes", and I have declared a NotOnList event procedure to take care of adding a value not on the list. Now, my problem is that, even though when I enter a value not on the list it appropriately opens the form to add a new value, the pop-up that says "The text you entered isn't an item in the list" still comes up. This seems pretty unreasonable since I already wrote an
1
2242
by: magic man via .NET 247 | last post by:
hi everyone i have a c# application that uses multithreading toconnect to sql server and execute a stored procedure on theserver. i am using a dataset,sqlcommand,dataadapter and adatagrid to carry out the process on a background thread andeverything goes well but the problem arrises when i created astop button that attempts to cancel the operation of datasetfilling(somtimes the query takes much time and i need to cancelthe operation) so that...
2
1595
by: McGeeky | last post by:
I use page_load to call a stored procedure and populate the form. When the user clicks the OK button on the form I have implemented an event handler behind it (OKButton_Click()) that calls another stored procedure to insert a record in the database then navigate to a success page. However, when the OKButton_Click() is called the page_load event is also called. This unnescessarilly sets up the page again. How can I stop page_load event...
3
1716
by: Roger Withnell | last post by:
I have a framed website. I plan to include in default.asp a routine to check if the annual subscription is due from the records in the People table. If so, then the routine would send emails to those who are due and update the table that this had been done, so that it is only done once. If session 1 is doing just this, session 2 (and 3 and n) could be doing the same thing.
51
54821
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() # This thread is expected to finish within a second
1
1070
by: Simone | last post by:
Hello In visual studio when I am debugging my ASP. net code if I hit "stop" the procedure I am in will still finish itself and doesn't stop where I expect it to stop. I remember in VB when you stop your code it stop at the exact line you're on. Now if I stop at the beginning at the procedure or function the code will still continue until the end sub/end function.
1
3502
by: pssheba | last post by:
Hi, My sp creates an error report. at a certain stage i want it to stop running if there are errors in thar report. I wrote: DECLARE @myparam INTEGER SELECT @myparam=COUNT(*) FROM report_errors1 IF (@myParam>0) BEGIN print 'stop running due to existing errors ! '
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.