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(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
updateOptionsLi stView()
End Sub
And in the seperate code module
Public Sub updateOptionsLi stView()
Dim form As New options()
form.ListBox1.I tems.Add(System .IO.Path.GetFil eNameWithoutExt ension("test"))
End Sub
If the line
"Me.ListBox1.It ems.Add(System. IO.Path.GetFile NameWithoutExte nsion("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 updateOptionsLi stView()
options.ListBox 1.Items.Add(Sys tem.IO.Path.Get FileNameWithout Extension("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(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
updateOptionsLi stView()
End Sub
And in the seperate code module
Public Sub updateOptionsLi stView()
Dim form As New options()
form.ListBox1.I tems.Add(System .IO.Path.GetFil eNameWithoutExt ension("test"))
End Sub
If the line
"Me.ListBox1.It ems.Add(System. IO.Path.GetFile NameWithoutExte nsion("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 updateOptionsLi stView()
options.ListBox 1.Items.Add(Sys tem.IO.Path.Get FileNameWithout Extension("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?
Comment