DOM1N8R:
I was just reading your posting and notice that you stated:
...a simple first project...
and
...take a text file filled with comma separated values and display them ...
and I really doubt that your instructor intended that you would use a DataGrid. That is a fairly advanced subject for a "first project."
And, the DataGrid is a terrible control, in my opinion, because it is what is called a "bound control" and bound controls are evil. You can use them without knowing how to really write proper code, but they will cause you a lot of headaches. Anyway, I'll save that for another time.
I think you should consider where you are in your book. What things have you covered so far. Probably Strings, Arrays, and things like that. Maybe also TextBoxes, ListBoxes and such. So If I was the one doing that project I would keep it in line with what I had already studied.
My instructions would read something like this:
OK, DOM, open a new VB.Net Windows Application (maybe name it FirstProject) and put a ListBox on the form. Make your ListBox about 2 inches across and maybe 4 inches high. Click on the TextBox to make sure it is selected and then you need to go to the Properties Window and name the ListBox MyListBox. Look down the list of Properties and find the Sorted Property and click on it. You will see a down arrow on the right and if you click on that you can change the Property to True. That is going to take care of the requirement
Also, just kind of look through the various Properties available for the ListBox Control so you start to get familiar with them.
Next, put a Command Button on the form, maybe near the bottom of the form and in the center.
Now just click once on the Command Button and then go back to the Properties Window.
Near the top of the Properties Window you will find the Name Property for the Command Button. Name it cmdShow.
Next, go down almost to the bottom of the Properties Window and find the Text Property. Change the Text to something like Show Items.
Go back and just click somewhere on your form.
Since you are using a comma separated value file I assume that your instructor gave you that file.
I don't know where you have it on your computer, but it would be good to put it somewhere like in a file on your C drive named ProjectFiles or something like that, so you can easily write a path to the file.
Alright, back to your form. Double click on the Command Button and you will be taken to the code window and you will see the code for the click event of your button cmdShow and it will have something like:
PrivateSub cmdShow_Click(
ByVal sender
As System.Object,
ByVal e .........
and then
EndSub
Next, take the following code and cut and paste it into your code window between PrivateSub and Endsub:
Dim reader As IO.StreamReader
Dim inputLine As String
Dim fields() As String
reader = New IO.StreamReader("C:\TestFiles\CSVfile1.txt")
Do While reader.Peek() <> -1
inputLine = reader.ReadLine()
fields = inputLine.Split(","c)
For Each field As String In fields
MyListBox.Items.Add(field)
Next
Loop
reader.Close()
reader = Nothing
In the code above, change the file path C:\TestFiles\CSVfile1.txt to whatever the path to your file is on your computer.
OK, click on the tab for your Form at the top of code window and you should be back at your form with the controls on it.
Now go to the menus at the top screen and click on Build, then Build Solution.
An Output Window should appear near the bottom of your screen and hopefully it will say something like:
Build: 1 succeeded, 0 failed, 0 skipped
If that is what it says, then you are good to go.
Oh, one thing before we do the final step. click once anywhere on your form and then go to the Properties Window. Go down toward the bottom and find the StartPosition Property and click on it and select CenterScreen. This will make your project appear in the center of the screen when it runs.
Alright, now for the final test. Go back to the menus at the top of the screen and click on Debug and then Start without Debugging, and keep your fingers crossed.
Your project should appear in the middle of your screen. Click on the Show Items button and you should see the items that were in your CSV file appear in the ListBox in alphabetical order.
Alright, I am almost done, but you have some work left to do.
I don't usually just do someone's homework projects for them, but I expect that you will now study that code and using your book to look up parts you don't understand, you will figure out just what it is doing and how it is doing it.
Good Luck and study hard.