Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 29th, 2004, 12:10 PM
xtremcoder xtremcoder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Houston, TX
Posts: 131 xtremcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 36 m 52 sec
Reputation Power: 6
Send a message via AIM to xtremcoder Send a message via Yahoo to xtremcoder
for each loop?

i dont have any of my books here at work, so i figured id ask here.

let me explain my situation, and go from there.

i have two tables (lets call them t1 and t2) that have the same exact fields, just different data. i need to compare each field in t1 to each field in t2. then go back and compare each record in t2 to each record in t1. i was thinking a nested for loop (coming from a C++ background) but i remember something about a for each loop in vb? can you have a for each loop and have the lcv be the recordset? for example:

for each recordSet in something?

thanks alot!

Reply With Quote
  #2  
Old January 29th, 2004, 01:14 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
yeah... there are two properties that you will want to use - recordcount and field... here's an abbreviated example
Code:
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim otherrs As New ADODB.Recordset
Dim i As Integer
Dim j As Integer

For i = 0 To (rs.RecordCount - 1)
    For j = 0 To (rs.Fields.Count - 1)
        'Do field comparison here
        rs.Fields(j) = otherrs.Fields(j)
    Next j
    'do record comparisons here
    'then do
    rs.MoveNext
    otherrs.MoveNext
Next i
End Sub

Reply With Quote
  #3  
Old January 29th, 2004, 02:17 PM
xtremcoder xtremcoder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Houston, TX
Posts: 131 xtremcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 36 m 52 sec
Reputation Power: 6
Send a message via AIM to xtremcoder Send a message via Yahoo to xtremcoder
awesome... im not exactly sure that is what im looking for, but it is definetely a start. the recordcount property is going to be what ill use, more than likely. i think the code you wrote out, compares each field in each record. i only need to compare sku #s, one per record.... i can modify the code to get it to do what i want... thanks alot! looks like i dont need a for each loop!

Reply With Quote
  #4  
Old January 29th, 2004, 03:15 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
nope.. but you can use the fields() method with the zero-based index of the fields that you want to compare.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > for each loop?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT