Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. easy question on combo box

easy question on combo box

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasequestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IlanTal
    wrote on last edited by
    #1

    I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan

    W D 2 Replies Last reply
    0
    • I IlanTal

      I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan

      W Offline
      W Offline
      whoispiyush
      wrote on last edited by
      #2

      why can't you use Request.form("id of combobox").value it returns index of number selected by user when he leaves the form use document.all("idofcombobox").value in javascript for same value without post back form

      I 1 Reply Last reply
      0
      • W whoispiyush

        why can't you use Request.form("id of combobox").value it returns index of number selected by user when he leaves the form use document.all("idofcombobox").value in javascript for same value without post back form

        I Offline
        I Offline
        IlanTal
        wrote on last edited by
        #3

        Visual Basic doesn't understand "Request" and since I've never used it, neither do I. While I'm still in the form, I have the combo box. It is called NumSamp. It seems to me that I ought to be able to query NumSamp in some easy way to find out which value in a list of values was chosen. In fact, NumSamp.SelectedIndex() gives me the correct offset in the list of values. I'm just missing the next step: given the index, what is the value of the entry? Thanks, Ilan

        W 1 Reply Last reply
        0
        • I IlanTal

          I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan

          D Offline
          D Offline
          Dave Sexton
          wrote on last edited by
          #4

          Use NumSamp.SelectedItem. If you're coding with Option Strict On use the .ToString() method as well. Sample

          Private Sub Button1_Click(...) Handles Button1.Click
          'pass value of selected item to Form2
          Dim frm2 As New Form2
          frm2.Text = Me.ComboBox1.SelectedItem.ToString
          frm2.Show()
          End Sub

          I 1 Reply Last reply
          0
          • D Dave Sexton

            Use NumSamp.SelectedItem. If you're coding with Option Strict On use the .ToString() method as well. Sample

            Private Sub Button1_Click(...) Handles Button1.Click
            'pass value of selected item to Form2
            Dim frm2 As New Form2
            frm2.Text = Me.ComboBox1.SelectedItem.ToString
            frm2.Show()
            End Sub

            I Offline
            I Offline
            IlanTal
            wrote on last edited by
            #5

            Thanks, It was under my nose all the time and somehow I missed it. As I expected, it is really easy.

            1 Reply Last reply
            0
            • I IlanTal

              Visual Basic doesn't understand "Request" and since I've never used it, neither do I. While I'm still in the form, I have the combo box. It is called NumSamp. It seems to me that I ought to be able to query NumSamp in some easy way to find out which value in a list of values was chosen. In fact, NumSamp.SelectedIndex() gives me the correct offset in the list of values. I'm just missing the next step: given the index, what is the value of the entry? Thanks, Ilan

              W Offline
              W Offline
              whoispiyush
              wrote on last edited by
              #6

              NumSamp.SelectedIndex.value will solve your problem

              I 1 Reply Last reply
              0
              • W whoispiyush

                NumSamp.SelectedIndex.value will solve your problem

                I Offline
                I Offline
                IlanTal
                wrote on last edited by
                #7

                Thanks for your kind answer.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups