We help IT Professionals succeed at work.
Get Started

Can you Use StreamReader In Public Module / Function- I'm trying Loading Text Files In to a Combo Box vb.net

62 Views
Last Modified: 2015-09-13
Hi Guys,

I have a program I'm working on with multiple combo boxes on multiple forms. A lot of the combo boxes are labeled the same name. Ie ComboBox1.

Can you Use StreamReader In Public Module / Function

 I'm trying Loading Text Files In to a Combo Boxes. I have multiple forms with same combo boxes. I would like to reduce the amount of code im using...

This is an example of how im reading my text file in to the combo box.

   Dim objReader_TextFile1 As New System.IO.StreamReader("c:\\Text_Files\TextFile1.txt")
             
                    Do While Not objReader_TextFile1.EndOfStream
                ComboBox1.Items.Add(objReader_TextFile1.ReadLine)
            Loop
            objReader_TextFile1.Close()

Or is there a better / different way of doing this?
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE