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. vb.net access value in combo box

vb.net access value in combo box

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasetutorialquestion
1 Posts 1 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.
  • C Offline
    C Offline
    classy_dog
    wrote on last edited by
    #1

    In a VB.net 2010 desktop application, I just added 2 combo boxes to the desktop. The first combo box lists the name of the various users. The first combo box that lists the names of various users has the following values added to the collection: 'ANN','KARON'. The second combo box lists the names of Access 2013 database files that the user has access to. I have the following code:

    cboUser.SelectedIndex = 0
    Dim dirAccessFiles As String() = Directory.GetFiles("H:\FilesTest", "*.accdb")
    Dim list As New List(Of String)()
    For Each dir As String In dirAccessFiles
    If String.Equals(Path.GetFileNameWithoutExtension(dir).Substring(0, 3), cboUser.SelectedValue) Then
    list.Add(Path.GetFileNameWithoutExtension(dir))
    End If
    Next

        list.Sort()
         For i As Integer = list.Count - 1 To 0 Step -1
             cboAccessFile.Items.Add(list(i))
         Next
    

    In the following line of code, "If String.Equals(Path.GetFileNameWithoutExtension(dir).Substring(0, 3), cboUser.SelectedValue)" , The cboUser.SelectedValue has nothing in it. However I know the collection has something in it since I can see the values in the collection of the combo box. Thus can you tell me how to change the code so that the value of 'ANN' can be located in the if statement I just listed above?

    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