473,626 Members | 3,221 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stopping a For Next Loop until a value is return from another form

3 New Member
Hi,

I am pretty new to VB.net and am having trouble figuring out how to do this.

I have an app that copies data from one datasource to another.

I have it set to run through a for loop for each row in SourceDataTable .

for each row i get the a value that is not an ID and I have a funciton that compares this to a column in the Destination, and i recieve the ID back if it exits and nothing if it doesn't. This work fine the next part I am having trouble with.

I then have an IF statement that test if the ID is returned or not then chooses whether to run the Insert if it does exist or If the ID doesn't exist i want to open up a form where i can choose (and return) the ID i want to use (i know how to set all this up)

the problem i am having is that i the for loop that is transferring data from the source to the destination keeps going.

here is the for loop i am using, i just need to know how to stop the loop from running while i am retrieving strID from a new form. i have put this bit in red

Expand|Select|Wrap|Line Numbers
  1.  
  2. For i = 0 To dbDataTable.Rows.Count - 1
  3.  
  4. 'get the value for the ID to compare
  5. str1 = dbDataTable.Rows(i)(0).ToString
  6. str1 = Replace(str1, "'", "")
  7.  
  8. 'compare the source ID to the destination ID column to see if it is to be update or insert
  9. strID = Compares.ReturnDestinationID(dbDestinationDataset, str1)
  10.  
  11. If strID = "" Then
  12.  
  13. 'open form for retrieving ID to use for insert
  14. strID = Value recieved back from other form
  15.  
  16. 'run insert sub using the new strID
  17. Inserts.InsertDataRowToDestination(dbDataTable.Rows(i), strID)
  18.  
  19. Else
  20.  
  21. 'this is a sub I have created to insert the data row to the destination table
  22. Inserts.InsertDataRowToDestination(dbDataTable.Rows(i), strID) 
  23.  
  24. End If
  25.  
  26. Next
  27.  
any direction will be very greatly appreciated
Jul 25 '08 #1
1 1080
DrBunchman
979 Recognized Expert Contributor
Hi pfildes,

You can use
Expand|Select|Wrap|Line Numbers
  1.  
  2. Exit For
  3.  
to stop the loop.

Hope this helps,

Dr B
Jul 25 '08 #2

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

Similar topics

2
2478
by: news.cablevision.qc.ca | last post by:
Hi! I want, using a form, enter a number and then, read that number of records in a database and store information in variables. The only way I see to do this is to do a FOR...NEXT to the number entered in the form, and then include the database reading into it. THE PROBLEM: <%
14
5450
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
23
3909
by: ern | last post by:
I have a program that runs scripts. If the user types "script myScript.dat" the program will grab commands from the text file, verify correctness, and begin executing the script UNTIL... I need a way to stop the execution with user input. I was thinking something like this: while(user hasn't pressed 'any key'){ keepExecutingScript(); }
1
5208
by: Jim P. | last post by:
I'm having trouble returning an object from an AsyncCallback called inside a threaded infinite loop. I'm working on a Peer2Peer app that uses an AsyncCallback to rerieve the data from the remote peer. I have no problem connecting the peers and streaming Network Streams. When the incoming data is finished recieving, I act upon it. This works great as long as all of the code is inside my form. I want to build the networking code into a...
12
1483
by: melanieab | last post by:
Hi, I'm trying to check and see if something other than numbers (either the +, -, *, or /) are entered into a textbox, where bigR is what I call the text in the textbox. I can get what was entered and where along the string (the where part is the first section of below). I'm running into trouble just after that. I tested what the value of breakpt and got 3, which it should be if entering something like 100 + 200. But when I run the for...
6
8083
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class functions __init__, SvcStop, and SvcDoRun (which contains my server code). After registering the service, I am able to start it with no problems. However, it never stops correctly (net stop returns "service could not be stopped") and service is left...
11
1854
by: Steve | last post by:
I'm having a problem with my Thread usage and I think the general design of how I'm working with them. My UI class calls a method in another class that does a lot of work. That "worker" class looks something like this(pseudo code): class WorkerClass { Thread _listenerThread; public WorkerClass() {
4
2042
by: bjm | last post by:
I am writing a program that will automate a series of application installations. I want to give the user the option of stopping the program's execution in between installations (for example, give the user the chance to stop the program after the second installation before it continues on to the third installation). However, I want the user to be able to start the installations and walk away as well, so I can't ask the user if he wants to...
0
6533
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file /new_file/prob1.rec started. Please wait.... In while loop of request searching *** glibc detected *** ./a.out: free(): invalid next size (normal): 0x099da890 *** ======= Backtrace: ========= /lib/libc.so.6
0
8265
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
8637
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...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
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
7193
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
6125
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
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
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
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.