473,498 Members | 1,776 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 1070
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
2464
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...
14
5419
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...
23
3889
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...
1
5189
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...
12
1475
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...
6
8016
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...
11
1840
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...
4
2029
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...
0
6516
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...
0
7004
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...
0
7208
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...
0
7379
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...
1
4915
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...
0
4593
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...
0
3095
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...
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.