Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 293697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:17:58+00:00 2026-05-12T06:17:58+00:00

I have a sub that handles when 14 ComboBoxes have their Index changed. I

  • 0

I have a sub that handles when 14 ComboBoxes have their Index changed. I am able to cast the sender of the event, and obtain properties from there. However, after that, I want to be able to change the properties of the actual sender, rather than the cast one. How would I do this?

Current code:

Private Sub ComboBoxIndexChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged [etc]
        Dim myComboBox As ComboBox = sender

        Select Case myComboBox.Text
            Case "Will"
                Me.Controls(myComboBox.Name).Text = "555-555-555"
            Case "Bob"
                Me.Controls(myComboBox.Name).Text = "555-124-1234"
            [etc]
        End Select
    End Sub
End Class

As you can see, I am currently trying to use

Me.Controls(myComboBox.Name).Text

But I get the error: Object reference not set to an instance of an object.

What can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:17:58+00:00Added an answer on May 12, 2026 at 6:17 am

    The sender parameter in an event handler will (typically) contain a reference to the object that raised the event. In the case of the SelectedIndexChanged event of a ComboBox control, it will be the ComboBox that had its SelectedIndex property changed. So in your code sample above myComboBox is referring the ComboBox that raised the event.

    To clarify: if you select an item in the drop-down list of a ComboBox control, so that it raises the SelectedIndexChanged event, the sender parameter of the event handler will be that same ComboBox, not a copy of it. This is true for all reference types.

    Had it been a value type raising the event it would have been a completely different story, but that is a very rare case (it it is never the case when it comes to controls on a form).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SubSelectVC that handles sub-selection choice that is presented modally from a
I have the following hover script that handles the sliding down of sub menus
In a module i have a sub that create modalpopup and show result of
I have a sub query that returns one column, showing as GroupType, I then
I have a sub form that looks like a datasheet view. It returns prices
We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent
I have just found a script we are using which has a sub that
I have a directory with multiple sub directories that contain .doc files. Example: C:\Users\tmedina\Documents\testenviroment\Released\500\test0.doc
I have a sub form in Access: The CopyNo is a combobox that lets
I have a ubuntu pc's in internal sub-network that I'm running mongo on them.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.