I have built a DataTable from my database. Then I am looping through the rows and trying to access a string, however the value is being returned as each character in the string.
For Each theseRows In DisplayForm.MainTab.Rows
If theseRows.Item("Last_Name") = userLast And theseRows.Item("First_Name") = userFirst Then
For Each RGCode As String In theseRows.Item("Trap_Code")
MessageBox.Show(RGCode)
Next
End If
Next
The Trap_Code values are two or three letter strings, the returned value is each letter once at a time. The loop seems to cycle through the individual characters of the string as an array rather than display the entire value, which is what I was hoping for. Just looking for some help and advice.
Thank you,
RL.
You’ve specifically asked to loop over the value of
Trap_Code:That’s fetching a single value (
theseRowsis just one row, remember – you may want to change the variable name) which is a string. You’re then iterating over the string in the only way you can – as a sequence of characters.Given that you’re already looping over the rows, why are you looping at all within your
Ifstatement? I suspect you just want:Or with a better name for a single row (and less indentation to avoid scrolling):