Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Arrays

Arrays

Scheduled Pinned Locked Moved Visual Basic
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larry White
    wrote on last edited by
    #1

    I am trying to create an order form for my users. The form has a listbox where the user selects multiple names and it populates a textbox for user confirmation. The selection process also creates an array used to create a SQL database record for each name in the list. This part works. Here is the code I have so far:

    Sub xxx
    reader1 = dr1.ExecuteReader()
    While reader1.Read()
    values1.Add(reader1.Item("Name"))
    values2.Add(reader1.Item("Emplid"))
    End While
    lbName.DataSource = values1
    lbEmplid.DataSource = values2
    End Sub
    Sub xxx
    rtbName.Text = Nothing
    rtbEmplid.Text = Nothing
    For i = 0 To lbName.SelectedItems.Count - 1
    With arrList2
    .ToArray()
    End With
    rtbName.Text = rtbName.Text & lbName.SelectedItems(i) & vbCrLf
    Next
    i = Nothing

    The problem I'm running into is, I need to collect the Emplid along with the name. I'm trying to set it up by selecting only the name with the Emplid selected at the same time. I can combine the two within the SQL statement, but I need to populate each field of the database entry separately. Any help would be greatly appreciated.:) Thank you,

    LWhite

    C 1 Reply Last reply
    0
    • L Larry White

      I am trying to create an order form for my users. The form has a listbox where the user selects multiple names and it populates a textbox for user confirmation. The selection process also creates an array used to create a SQL database record for each name in the list. This part works. Here is the code I have so far:

      Sub xxx
      reader1 = dr1.ExecuteReader()
      While reader1.Read()
      values1.Add(reader1.Item("Name"))
      values2.Add(reader1.Item("Emplid"))
      End While
      lbName.DataSource = values1
      lbEmplid.DataSource = values2
      End Sub
      Sub xxx
      rtbName.Text = Nothing
      rtbEmplid.Text = Nothing
      For i = 0 To lbName.SelectedItems.Count - 1
      With arrList2
      .ToArray()
      End With
      rtbName.Text = rtbName.Text & lbName.SelectedItems(i) & vbCrLf
      Next
      i = Nothing

      The problem I'm running into is, I need to collect the Emplid along with the name. I'm trying to set it up by selecting only the name with the Emplid selected at the same time. I can combine the two within the SQL statement, but I need to populate each field of the database entry separately. Any help would be greatly appreciated.:) Thank you,

      LWhite

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Larry White wrote:

      values1.Add(reader1.Item("Name")) values2.Add(reader1.Item("Emplid"))

      I suspect you want to create a struct which connects these two values and build a collection of those structs.

      Larry White wrote:

      With arrList2 .ToArray() End With

      Why would you do this to call one method ?

      Larry White wrote:

      lbName.SelectedItems

      Items in a combobox can also have a value stored against them, you can store the Id there.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      L 1 Reply Last reply
      0
      • C Christian Graus

        Larry White wrote:

        values1.Add(reader1.Item("Name")) values2.Add(reader1.Item("Emplid"))

        I suspect you want to create a struct which connects these two values and build a collection of those structs.

        Larry White wrote:

        With arrList2 .ToArray() End With

        Why would you do this to call one method ?

        Larry White wrote:

        lbName.SelectedItems

        Items in a combobox can also have a value stored against them, you can store the Id there.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        L Offline
        L Offline
        Larry White
        wrote on last edited by
        #3

        I am a relative beginner at VB.NET so my methods may be a little off. I am trying to pull the data from 2 fields from 1 table and creating a new record with name and employee id. I thought it would be a relatively simple process to capture an array with the name and ID, then use the array in the SQL insert variables to create each record. Thank you for responding,

        LWhite

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups