K
koosh34
VS2005 VB.net 2.0
I have a form called options with a ListBox1 on it, to fill the list box
from several events on the form I put the code to update the ListBox1 items
into a sub in a separate code module.
Private Sub options_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
updateOptionsListView()
End Sub
And in the seperate code module
Public Sub updateOptionsListView()
Dim form As New options()
form.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))
End Sub
If the line
"Me.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))"
is placed in the options_load sub it works but when I call it from the
separate code module it does not. I think this is because another instance
of the options form is being updated.
I also tried
Public Sub updateOptionsListView()
options.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))
End Sub
But I get a warning "Reference to a non-shared member requires an object
reference" and the ListBox does not update either.
How do I get around this problem?
I have a form called options with a ListBox1 on it, to fill the list box
from several events on the form I put the code to update the ListBox1 items
into a sub in a separate code module.
Private Sub options_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
updateOptionsListView()
End Sub
And in the seperate code module
Public Sub updateOptionsListView()
Dim form As New options()
form.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))
End Sub
If the line
"Me.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))"
is placed in the options_load sub it works but when I call it from the
separate code module it does not. I think this is because another instance
of the options form is being updated.
I also tried
Public Sub updateOptionsListView()
options.ListBox1.Items.Add(System.IO.Path.GetFileNameWithoutExtension("test"))
End Sub
But I get a warning "Reference to a non-shared member requires an object
reference" and the ListBox does not update either.
How do I get around this problem?