I have an issue within VB Express 2008 which I am struggling to resolve.
I am trying to take the information from 3 columns in a CSV file (ServerRef, ServerName, ServerIP) with no header row and populate 3 combobox's for users to select from to initiate an RDP connection.
So far I have gotten the following code, but I'm unable to use the information in the combobox's in other sub-routines and seem unable to move the information into a text box or dim's value field...

Private Sub Testing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Servers = (From line In IO.File.ReadAllLines("c:\Testing\Servers.csv") _
Where line.Length > 0 _
Let Items = line.Split(","c) _
Select New With _
    {.ServRef = Items(0), _
      .ServName = Items(1), _
      .ServIP = Items(2) _
    } _
 ).ToList

        For Each Machine In Servers
            Console.WriteLine("[{0} [{1}] [{2}]", _
                              Machine.ServRef, _
                              Machine.ServName, _
                              Machine.ServIP _
                  )
        Next

        ComboBox1.DataSource = Servers
        ComboBox1.DisplayMember = "ServRef"

        ComboBox2.DataSource = Servers
        ComboBox2.DisplayMember = "ServName"

        ComboBox3.DataSource = Servers
        ComboBox3.DisplayMember = "ServIP"
    End Sub

Any help greatly received

Hi,

You can try something like this:

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    TextBox1.Text = ComboBox1.SelectedItem
End Sub

Tried that but I get "Conversion from type 'VB$AnonymousType_2(Of String,String,String)' to type 'String' is not valid.".

Ok I have got the text I need into a text box using:

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox1.Clear()
        TextBox1.Text = ComboBox3.Text
        TextBox1.Refresh()
    End Sub

The problem I now face is that the change doesn't automatically update the textbox. It seems when I change it, it will pick up the previous value that was in the field.
Getting further, but still not quite there.

I have managed to get this working. If I ignore the text box and call the value directly this works. So I have simply removed the text box as it's not actually required, it was for validation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.