Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Readline (http://www.programmingforums.org/showthread.php?t=14842)

RachelHelps Jan 1st, 2008 4:22 AM

Readline
 
Hi,

I always get stuck when I try to do readlines. I am writing a program that is suppose to open a file when you click on open file, then the file that it opens should read the first part and do a item add to a combo box. Any help would be appreciated. If you need more info please let me know.

Thanks,

Rachel

null_ptr0 Jan 1st, 2008 12:10 PM

Re: Readline
 
System.IO.File.ReadAllLines("./myfile.ext")[0]
Read the .NET API docs, and perhaps bookmark the page:
http://msdn2.microsoft.com/en-us/library/ms229335.aspx

RachelHelps Jan 1st, 2008 12:17 PM

Re: Readline
 
Thank you :)

Yes, I understand it could be done this way...but how would I do it if I don't know the name of the file? The user has to pick the file and when they hit "Ok" the file should be read.

Rachel

mattireland Jan 1st, 2008 12:57 PM

Re: Readline
 
You'd need to use an open file dialog box.

MSDN have an excellent tutorial video series on this sort of stuff. Go to this URL:

http://msdn2.microsoft.com/en-us/vstudio/aa700732.aspx

and then scroll down to the bottom of the page. From memory, dialog controls are covered in Lesson 4.

Regards,

Matt. I

RachelHelps Jan 1st, 2008 1:07 PM

Re: Readline
 
Right. I am using an open dialog box. But once the file is opened I don't know how to read the file to put the first part of the text into a combo box. The code should read the text line by line and put only the first part into a combo box so that when the arrow is selected you should see a choice of 100, 200, 300, etc...

I'll go to the link. I have tried these tutorials, but they do not go into great detail. I hope this one does.

Thanks,

Rachel

mattireland Jan 1st, 2008 1:58 PM

Re: Readline
 
The other thing that you could benefit from is probably getting a good book. There are loads around and if you want detail are probably much better than most tutorials on the internet.

Klipt Jan 2nd, 2008 4:15 AM

Re: Readline
 
Instead of hard coding the filename (System.IO.File.ReadAllLines("./myfile.ext")[0]) just use the dialog's filename property after displaying it. E.g.

:

if(openFileDialog1.ShowDialog() == DialogResult.OK )
        comboBox1.Text = System.IO.File.ReadAllLines(openFileDialog1.FileName)[0]



All times are GMT -5. The time now is 4:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC