martin_d_bell
Newcomer
- Joined
- Oct 8, 2004
- Messages
- 17
Hi All,
I am quite new to programming and have grasped most things except for Nested For Loops which just will not click!!
I am trying to write a small application which loops through two datasets and compares values in dataset1 to the values in dataset2. So far my code looks like this
I have a listview and a button on my form, when the user clicks the button the values which do not match need to be displayed in the listview.
I just need help with the Nested For Loop as at the minute it lists all of the values in the ListView whether they match up or not.
Thanks
Martin
I am quite new to programming and have grasped most things except for Nested For Loops which just will not click!!
I am trying to write a small application which loops through two datasets and compares values in dataset1 to the values in dataset2. So far my code looks like this
Code:
lblCheckDone.Visible = False
lvbPartCodes.Items.Clear()
If IsDBNull(DsPOPPartCodes1.POP_Parts_Costs) = False Then DsPOPPartCodes1.POP_Parts_Costs.Clear()
SqlDAPOPPartCodes.Fill(DsPOPPartCodes1.POP_Parts_Costs)
If IsDBNull(DsWDPartCodes1.POP_WDPcodes) = False Then DsWDPartCodes1.POP_WDPcodes.Clear()
SqlDAWDPartCodes.Fill(DsWDPartCodes1.POP_WDPcodes)
Dim x As Int16
Dim y As Int16
Dim PCode As String
Dim PCodeDesc As String
Dim Counter As String
x = 0
y = 0
Counter = 0
For y = 0 To DsWDPartCodes1.POP_WDPcodes.Rows.Count - 1
PCode = DsWDPartCodes1.POP_WDPcodes.Rows(y).Item(1)
PCodeDesc = DsWDPartCodes1.POP_WDPcodes.Rows(y).Item(2).ToString
For x = 0 To DsPOPPartCodes1.POP_Parts_Costs.Rows.Count - 1
If " " + Replace(PCodeDesc, ",", "") <> DsPOPPartCodes1.POP_Parts_Costs.Rows(x).Item(2).ToString Then
Dim lvbPartRow As New ListViewItem(PCode)
lvbPartRow.SubItems.Add(PCodeDesc)
lvbPartCodes.Items.Add(lvbPartRow)
Counter = Counter + 1
lblCheckDone.Text = Counter
Exit For
End If
Next
Next
SqlDAWDPartCodes.Update(DsWDPartCodes1.POP_WDPcodes)
lblCheckDone.Visible = True
I have a listview and a button on my form, when the user clicks the button the values which do not match need to be displayed in the listview.
I just need help with the Nested For Loop as at the minute it lists all of the values in the ListView whether they match up or not.
Thanks
Martin