Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8136255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:42:18+00:00 2026-06-06T10:42:18+00:00

I have built a DataTable from my database. Then I am looping through the

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:42:19+00:00Added an answer on June 6, 2026 at 10:42 am

    You’ve specifically asked to loop over the value of Trap_Code:

    For Each RGCode As String In theseRows.Item("Trap_Code")
    

    That’s fetching a single value (theseRows is 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 If statement? I suspect you just want:

    For Each theseRows In DisplayForm.MainTab.Rows
        If theseRows.Item("Last_Name") = userLast And theseRows.Item("First_Name") = userFirst Then
            MessageBox.Show(theseRows.Item("Trap_Code"))
        End If
    Next
    

    Or with a better name for a single row (and less indentation to avoid scrolling):

    For Each row In DisplayForm.MainTab.Rows
      If row.Item("Last_Name") = userLast And row.Item("First_Name") = userFirst Then
        MessageBox.Show(row.Item("Trap_Code"))
      End If
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem trying to remove a row from a datatable in
I have a datatable containing system profile names. This table is then assigned as
I built an application which displays the records from database in the window and
I have pages of data, pulled from a database. I need to be able
I have an existing DataTable built in Wicket 1.5 as follows: The Page's java
I have a program that get sensors data from a Como database and put
I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
I have built UI, its like a search engine for BioProcess/Disease--> Genes. e.g., User
I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming
I have built a site in wordpress and the home page is really screwed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.