Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Could someone assist me in coding a simple button to load txt to combo box?

vb.net combobox text file selection

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#13 zeroGiven


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 61 posts

Posted 29 March 2013 - 05:00 AM

I think you're wanting an openfiledialog.

also, the issue above is that everytime you click, you're reading and processing the textfile. You will need to clear the items of the comboboc prior to the for each statement



       Dim ofd As New OpenFileDialog
        ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim sr As StreamReader = New StreamReader(ofd.filename)
            For Each item As String In sr.ReadToEnd().Split(Environment.NewLine)


         end if

Then you will want to double-click on your combobox and in the default event that comes up, set your label = combobox1.text


#14 codegirl


    CC Regular

  • Member
  • PipPipPip
  • 36 posts

Posted 30 March 2013 - 12:51 AM

Hey ,

 Thanks and for the label. I tried putting "Label1.Text = item" or "Label1.Text = ComboBox1.SelectedText" underneath Combobox.items but the label is not changing and showing as I select each line in combobox. 

Edited by codegirl, 30 March 2013 - 12:52 AM.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download