User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 375,225 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,218 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:

Loading A Text File into a Array into a Listbox

Join Date: May 2008
Posts: 5
Reputation: Sliders is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Sliders's Avatar
Sliders Sliders is offline Offline
Newbie Poster

Loading A Text File into a Array into a Listbox

  #1  
May 8th, 2008
I am usually not keen for asking for help in these kind of situations but I am really stumped when it comes to this, all I really need is a good step in the right direction and I should be (hopefully) fine.

I am currently writing an airplane seating program for my VB class. What I am trying to do is load a text file into an array and then out put it into the list box.

  1. Dim seat(15, 6) As Double
  2. Dim sr As IO.StreamReader = IO.File.OpenText("plane.txt")
  3. For row As Integer = 0 To 6
  4. For col As Integer = 0 To 15
  5. seat(row, col) = CDbl(sr.ReadLine)
  6. Next
  7. Next
  8. listSeat.Items.Clear()
  9. listSeat.Items.Add("ABC DEF")
  10. Do While sr.Peek <> -1
  11. listSeat.Items.Add(sr.ReadLine)
  12. Loop
  13. sr.Close()
  14. End Sub

The setup for the txt file is like this:

... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...
... ...

When I execute the program I get a InvalidCastException which said {"Conversion from string "V.. ..." to type 'Double' is not valid."}

The "V.. ...." is from the txt file, from this error from what I am trying to comprehend is that its trying to convert the whole line to double, but I am not sure on how to go about going fixing this small problem, because If i can figure this out then I can figure out the rest of my problem.

Thanks in advanced
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 3:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC