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

  • Home
  • SEARCH
  • 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 1016251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:31:20+00:00 2026-05-16T10:31:20+00:00

I am populating combo box from database. In debug i can see that the

  • 0

I am populating combo box from database. In debug i can see that the combo box has been populated .

here is the code

Private Sub ComboID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboID.SelectedIndexChanged

        Dim data(21) As String
        Try
            t_code.Text = ComboID.SelectedItem(0)
            ComboID.Visible = False
            data = getData(t_code.Text)

            populateFields(data)


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

but when i run this program i get error:Object variable or with block variable not set error

i would really appreciate your help.
Thanks

  • 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-16T10:31:20+00:00Added an answer on May 16, 2026 at 10:31 am

    Just knowing that the combobox is populated is not enough. You should still be testing for

    SelectedIndex >= 0

    It is possible that SelectedIndex is changing to -1 if the user clears the selection.

    Of course, it is also quite likely that getData is returning Nothing and populateFields can’t handle that. It would probably throw a

    If data isNot Nothing
    end if
    

    test around the populateFields call, too. It never hurts to test for edge cases.

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

Sidebar

Related Questions

I have a combo box. The values are populating in combo box from DB.
How to speed up a combo box populating speed? Academically speaking, imagine that a
I am dynamically populating a winforms combo box by creating a list from a
im populating the data in the combo box using dataset tables...with some table name..now
I can get the list of country names using below code, (copied from somewhere
I am populating a Dojo Combobox dropdown with values from JSON. The code below
I am populating a treeview control, c# visual studio 8, using this code: private
I am populating a combobox dropdown with node fields from an Xml document. I
I have a ComboBox that I am populating with a list of parts for
I am using a ToolStripComboBox to list some data. I am populating this combo

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.