Very simple error problems with objects & listboxes

Anjow

New member
Joined
Dec 7, 2005
Messages
2
Programming Experience
1-3
Hi,

I'm a newbie to VB.NET - I studied VB 5&6 in college, but I've mostly forgotten about it. Anyhow, on my university human-computer interaction course I've got to make an MP3 player with playlist capability.

I am using a DriveListBox, DirListBox and FileListBox to select the file to add to the playlist - however the problem arises when I actually try to add the file. The doubleclick method is meant to take the file's path and insert it into the listview on the other form.

VB.NET:
Private Sub FileListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.DoubleClick
        OtherForm.lst_playlist.Items.Add(New ListViewItem(FileListBox1.Path.ToString)) 'Supposed to add that to the playlist on form1
End Sub

Sorry if that's a bit messy. Anyhow, when I double click the item in the filelistbox at runtime I get an error saying:

An unhandled exception of type 'System.NullReferenceException' occurred in Mp3player1.exe

Additional information: Object reference not set to an instance of an object.

I must admit I don't understand much about object orientation etc. - I didn't pay much attention in class! So I don't really know why I'm getting this error. Also, I don't really know what information would be useful to you in diagnosing the problem - don't hesitate to ask for more info should it be needed.

Thanks,

Andrew
 
Thanks alot, I'll try that in a min! I figured that I wouldn't need to - as it is already in existence. Basically form 1 is the starting one, there's a button to show form 2, form 2 has the FileListBox on it which is meant to then operate on the ListView on form 1. If you get what I'm saying, I figured that I already had an instance of form 1 because I'd just come from it.

[Edit]

I've tried sticking "Dim OtherForm as new Form1" in the general area for Form2, yet now I get an error on running saying:

An unhandled exception of type 'System.StackOverflowException' occurred in Mp3player1.exe

And pointing to a bit of code within the windows form designed generated area, saying "MyBase.New()".
 
Back
Top