Listbox list to Array

  • Thread starter Thread starter John
  • Start date Start date
J

John

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.EventArgs) 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.Items

List.Add(filePath)

Next



Dim Item As String

For Each Item In List

Console.WriteLine(Item)

Next

Console.ReadLine()

End Sub
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top