Listbox list to Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Listbox list to Array

    Hi there,

    I've got a form with a listbox (lstWrkFiles) that populated with a number of
    files. I'm trying to pass this list of files to an array (so I can use it
    later). However, I've the code below "Sub FileArray()" is meant to fire
    when I click on the btnNext1 button, but nothing happens. Can anyone spot
    what I'm doing wrong?

    Thanks

    John

    Private Sub btnNext1_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles btnNext1.Click

    'Populate Array

    FileArray()

    End Sub





    Public Sub FileArray()

    Dim List As New ArrayList

    Dim filePath As String

    For Each filePath In lstWrkFiles.Ite ms

    List.Add(filePa th)

    Next



    Dim Item As String

    For Each Item In List

    Console.WriteLi ne(Item)

    Next

    Console.ReadLin e()

    End Sub


  • Q

    #2
    Re: Listbox list to Array

    Hey John,

    I tried out your code and it seems to work correctly.
    The output of your application goes to the debug-window.
    I think your problem is the following:
    I quote from MSDN help on "Console Class":

    " The console class provides basic support for applications that read
    characters from, and write characters to, the console.
    If the console does not exist, as in a Windows-based application, writes to
    the console are not displayed and no exception is raised."

    I hope this is of any help to you.

    Regards,

    Q

    "John" <JohnSickOfSpam @AOL.net> wrote in message
    news:uYcVuan9EH A.2012@TK2MSFTN GP15.phx.gbl...[color=blue]
    > Hi there,
    >
    > I've got a form with a listbox (lstWrkFiles) that populated with a number[/color]
    of[color=blue]
    > files. I'm trying to pass this list of files to an array (so I can use it
    > later). However, I've the code below "Sub FileArray()" is meant to fire
    > when I click on the btnNext1 button, but nothing happens. Can anyone spot
    > what I'm doing wrong?
    >
    > Thanks
    >
    > John
    >
    > Private Sub btnNext1_Click( ByVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles btnNext1.Click
    >
    > 'Populate Array
    >
    > FileArray()
    >
    > End Sub
    >
    >
    >
    >
    >
    > Public Sub FileArray()
    >
    > Dim List As New ArrayList
    >
    > Dim filePath As String
    >
    > For Each filePath In lstWrkFiles.Ite ms
    >
    > List.Add(filePa th)
    >
    > Next
    >
    >
    >
    > Dim Item As String
    >
    > For Each Item In List
    >
    > Console.WriteLi ne(Item)
    >
    > Next
    >
    > Console.ReadLin e()
    >
    > End Sub
    >
    >[/color]


    Comment

    • Q

      #3
      Re: Listbox list to Array

      Hey John,

      I tried out your code and it seems to work correctly.
      The output of your application goes to the debug-window.
      I think your problem is the following:
      I quote from MSDN help on "Console Class":

      " The console class provides basic support for applications that read
      characters from, and write characters to, the console.
      If the console does not exist, as in a Windows-based application, writes to
      the console are not displayed and no exception is raised."

      I hope this is of any help to you.

      Regards,

      Q

      "John" <JohnSickOfSpam @AOL.net> wrote in message
      news:uYcVuan9EH A.2012@TK2MSFTN GP15.phx.gbl...[color=blue]
      > Hi there,
      >
      > I've got a form with a listbox (lstWrkFiles) that populated with a number[/color]
      of[color=blue]
      > files. I'm trying to pass this list of files to an array (so I can use it
      > later). However, I've the code below "Sub FileArray()" is meant to fire
      > when I click on the btnNext1 button, but nothing happens. Can anyone spot
      > what I'm doing wrong?
      >
      > Thanks
      >
      > John
      >
      > Private Sub btnNext1_Click( ByVal sender As System.Object, ByVal e As
      > System.EventArg s) Handles btnNext1.Click
      >
      > 'Populate Array
      >
      > FileArray()
      >
      > End Sub
      >
      >
      >
      >
      >
      > Public Sub FileArray()
      >
      > Dim List As New ArrayList
      >
      > Dim filePath As String
      >
      > For Each filePath In lstWrkFiles.Ite ms
      >
      > List.Add(filePa th)
      >
      > Next
      >
      >
      >
      > Dim Item As String
      >
      > For Each Item In List
      >
      > Console.WriteLi ne(Item)
      >
      > Next
      >
      > Console.ReadLin e()
      >
      > End Sub
      >
      >[/color]


      Comment

      • John

        #4
        Re: Listbox list to Array

        Thanks for this Q. Does this mean that I can't use Console at all, or is
        there some other way to implement it?

        Thanks

        John
        "Q" <Q@nomail.be> wrote in message
        news:e$1GCDo9EH A.3820@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Hey John,
        >
        > I tried out your code and it seems to work correctly.
        > The output of your application goes to the debug-window.
        > I think your problem is the following:
        > I quote from MSDN help on "Console Class":
        >
        > " The console class provides basic support for applications that read
        > characters from, and write characters to, the console.
        > If the console does not exist, as in a Windows-based application, writes
        > to
        > the console are not displayed and no exception is raised."
        >
        > I hope this is of any help to you.
        >
        > Regards,
        >
        > Q
        >
        > "John" <JohnSickOfSpam @AOL.net> wrote in message
        > news:uYcVuan9EH A.2012@TK2MSFTN GP15.phx.gbl...[color=green]
        >> Hi there,
        >>
        >> I've got a form with a listbox (lstWrkFiles) that populated with a number[/color]
        > of[color=green]
        >> files. I'm trying to pass this list of files to an array (so I can use
        >> it
        >> later). However, I've the code below "Sub FileArray()" is meant to fire
        >> when I click on the btnNext1 button, but nothing happens. Can anyone
        >> spot
        >> what I'm doing wrong?
        >>
        >> Thanks
        >>
        >> John
        >>
        >> Private Sub btnNext1_Click( ByVal sender As System.Object, ByVal e As
        >> System.EventArg s) Handles btnNext1.Click
        >>
        >> 'Populate Array
        >>
        >> FileArray()
        >>
        >> End Sub
        >>
        >>
        >>
        >>
        >>
        >> Public Sub FileArray()
        >>
        >> Dim List As New ArrayList
        >>
        >> Dim filePath As String
        >>
        >> For Each filePath In lstWrkFiles.Ite ms
        >>
        >> List.Add(filePa th)
        >>
        >> Next
        >>
        >>
        >>
        >> Dim Item As String
        >>
        >> For Each Item In List
        >>
        >> Console.WriteLi ne(Item)
        >>
        >> Next
        >>
        >> Console.ReadLin e()
        >>
        >> End Sub
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • John

          #5
          Re: Listbox list to Array

          Thanks for this Q. Does this mean that I can't use Console at all, or is
          there some other way to implement it?

          Thanks

          John
          "Q" <Q@nomail.be> wrote in message
          news:e$1GCDo9EH A.3820@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Hey John,
          >
          > I tried out your code and it seems to work correctly.
          > The output of your application goes to the debug-window.
          > I think your problem is the following:
          > I quote from MSDN help on "Console Class":
          >
          > " The console class provides basic support for applications that read
          > characters from, and write characters to, the console.
          > If the console does not exist, as in a Windows-based application, writes
          > to
          > the console are not displayed and no exception is raised."
          >
          > I hope this is of any help to you.
          >
          > Regards,
          >
          > Q
          >
          > "John" <JohnSickOfSpam @AOL.net> wrote in message
          > news:uYcVuan9EH A.2012@TK2MSFTN GP15.phx.gbl...[color=green]
          >> Hi there,
          >>
          >> I've got a form with a listbox (lstWrkFiles) that populated with a number[/color]
          > of[color=green]
          >> files. I'm trying to pass this list of files to an array (so I can use
          >> it
          >> later). However, I've the code below "Sub FileArray()" is meant to fire
          >> when I click on the btnNext1 button, but nothing happens. Can anyone
          >> spot
          >> what I'm doing wrong?
          >>
          >> Thanks
          >>
          >> John
          >>
          >> Private Sub btnNext1_Click( ByVal sender As System.Object, ByVal e As
          >> System.EventArg s) Handles btnNext1.Click
          >>
          >> 'Populate Array
          >>
          >> FileArray()
          >>
          >> End Sub
          >>
          >>
          >>
          >>
          >>
          >> Public Sub FileArray()
          >>
          >> Dim List As New ArrayList
          >>
          >> Dim filePath As String
          >>
          >> For Each filePath In lstWrkFiles.Ite ms
          >>
          >> List.Add(filePa th)
          >>
          >> Next
          >>
          >>
          >>
          >> Dim Item As String
          >>
          >> For Each Item In List
          >>
          >> Console.WriteLi ne(Item)
          >>
          >> Next
          >>
          >> Console.ReadLin e()
          >>
          >> End Sub
          >>
          >>[/color]
          >
          >[/color]


          Comment

          Working...