[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Get Selected Index from ComboBox

Hi EE,

I am trying to get the selected id for a combobox.

I have tried ... cC.StateID = Me.cboState.ValueMember(Me.cboState.SelectedIndex)  but it is an error.
What I need is the value that is saved in there from the code below.

Thanks

Dim ds As New DataSet
 
        If DatabaseToUse() = BizObjs.DBType.Access Then
            'Access Database
            Dim cFields As New cFieldTableNames
            cFields.ComboTable = msTblName
            SelectStr = cFields.ReturnComboString()
            Dim dc As New OleDb.OleDbConnection(ConnectionString)
            Dim da As New OleDb.OleDbDataAdapter(mSelectStr, dc)
 
            Try
                da.Fill(ds)
                dc.Close()
 
                cnt.DataSource = ds.Tables(0)
                cnt.DisplayMember = cFields.SendToCorrectFieldProcedure(3)
                cnt.ValueMember = cFields.SendToCorrectFieldProcedure(1)
'Returns the field Name of "StateID"
 
            Catch ex As Exception
 
                MessageBox.Show(ex.Message)
                Throw ex
 
            Finally
                dc.Close()
                da.Dispose()
            End Try
        End If

Open in new window

0
Sheritlw
Asked:
Sheritlw
  • 2
1 Solution
 
jpaulinoCommented:
Have you tried
Me.cboState.SelectedValue ?
0
 
SheritlwAuthor Commented:
Hi Jpaulino,

No I didn't try... I guess that just seemed so simple.  
I know after many years programming in VB 5 - VB 6, .Net seems like it requires a lot of code.
I always used sql server as a backend, until now and the backend handled everything.
In .Net it seems like you have to write a lot of code in the front end, no matter what.
Thanks,
Sheri
0
 
jpaulinoCommented:
Is just a matter of time and you get use to it. You will love in the end :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now