Solved

ListBox1_SelectedIndexChanged' is not declared.

Posted on 2006-07-14
13
344 Views
Last Modified: 2009-12-16
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."

0
Comment
Question by:aio419
  • 6
  • 4
13 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
Comment Utility
Have you created the event handler?
0
 

Author Comment

by:aio419
Comment Utility
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?
0
 
LVL 17

Assisted Solution

by:ZeonFlash
ZeonFlash earned 20 total points
Comment Utility
As Chaosian said, you're getting that error because you haven't created the event function yet.  Add the following to your code:

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub


You might also need to re-type the listbox (at least I did when trying it out):

        AddHandler CType(ListBox1, ListBox).SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged  'add the event.


0
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 20 total points
Comment Utility
Of course, the easy way to do this is

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub
0
 

Author Comment

by:aio419
Comment Utility
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:aio419
Comment Utility
and how much minimun point is requied to split it?
Thanks
0
 
LVL 24

Expert Comment

by:Jeff Certain
Comment Utility
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
0
 
LVL 24

Expert Comment

by:Jeff Certain
Comment Utility
I don't htink you can assign less than 20 points per person.
0
 

Author Comment

by:aio419
Comment Utility
okay i will increase points.
0
 

Author Comment

by:aio419
Comment Utility
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)
0
 

Author Comment

by:aio419
Comment Utility
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
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now