Link to home
Start Free TrialLog in
Avatar of aio419
aio419

asked on

ListBox1_SelectedIndexChanged' is not declared.

I am adding a list box to the form like this and i am getting this error.Can you please tell me how to fix it?

       Dim ListBox1 = New ListBox
        ListBox1.Size = New Size(200, 100)   'set size
        ListBox1.Location = New Point(10, 60)  'location
        AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged   'add the event.
        Me.Controls.Add(ListBox1)
        ListBox1.MultiColumn = True
        ListBox1.SelectionMode = SelectionMode.MultiExtended

 

    for AddressOf ListBox1_SelectedIndexChanged it is giving error
"  Name 'ListBox1_SelectedIndexChanged' is not declared."

Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Have you created the event handler?
Avatar of aio419
aio419

ASKER

While creating the event hander it is giving error
AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged  
it  do not like the 2nd part ie.AddressOf ListBox1_SelectedIndexChanged  
Is that what you asked?
SOLUTION
Avatar of ZeonFlash
ZeonFlash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aio419

ASKER

Thanks guys.
Okay. If you want to create a list box at run time, how we do that. Do we have to make the event hander first and then make the list box object? I am not getting that.
I thought I need to create the object and then write the event handler code.
Avatar of aio419

ASKER

and how much minimun point is requied to split it?
Thanks
You have to have the event handler written before you add the handler. Second argument to the AddHandler is the name of the subroutine that handles your event

Private Sub CreateControls
       Dim ListBox1 = New ListBox
        ListBox1.Size = New Size(200, 100)   'set size
        ListBox1.Location = New Point(10, 60)  'location
        AddHandler ListBox1.SelectedIndexChanged, AddressOf myHandler
        Me.Controls.Add(ListBox1)
        ListBox1.MultiColumn = True
        ListBox1.SelectionMode = SelectionMode.MultiExtended
End Sub

Private Sub myHandler(ByVal sender As Object, ByVal e As System.EventArgs)
' Do something here
End Sub
I don't htink you can assign less than 20 points per person.
Avatar of aio419

ASKER

okay i will increase points.
Avatar of aio419

ASKER

I increasd to 40.Still i do not get split point option!
i can not ignore ZeonFlash' answer either.B'cos he explained  my missing code from Chaosian's answer.

If i am  not getting any other option to split the points , i will award points to Chaosian .
i do not know Chaosian  can do anything to share it.
if that is the case i am very sorry ZeonFlash(even though it is only 20 points)
Avatar of aio419

ASKER

i do not see the Split Points in that screen.( i had done in the past with 'big' points)
If you(Chaosian) can do it,please do it.Accept your first comment as the answer and ZeonFlash's first comment as the assisted answer.
Thanks