![]() |
| ||
| Loading A Text File into a Array into a Listbox 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. 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 |
| ||
| Re: Loading A Text File into a Array into a Listbox Hi, Not sure, try this, change your code: listSeat.Items.Add(sr.ReadLine( )) Regards Veena |
| ||
| Re: Loading A Text File into a Array into a Listbox No, that didn't work. What also I tried to do is reverse the do while statement and the for statement but I got an out of bounds exception. |
| ||
| Re: Loading A Text File into a Array into a Listbox Hi, Try to declare reader oject like this : Dim sr As New System.IO.StreamReader("C:\plane.txt") Give complete path of the file.. REgards Veena |
| ||
| Re: Loading A Text File into a Array into a Listbox No I shouldn't have to give the complete path since the txt file is already where it is supposed to be in my project file, it will load just fine, but from what I see the problem is the way the code is written, and I have really no idea how to fix it. |
| ||
| Re: Loading A Text File into a Array into a Listbox Sorry for double posting but I think I fixed the code to make it better, and it works to an extent. Private Sub Chart_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load I don't get any out of bounds errors or null exception errors, but it won't output the text file into the list box for some reason |
| ||
| Re: Loading A Text File into a Array into a Listbox Hi, While populating the "Seat", populate the Listbox as well... Regards Veena |
| All times are GMT -4. The time now is 5:12 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC