473,388 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How can I load text file into list box in Visual Basic 6

I have downloaded a Visual Basic 6 application which pick a random name from a list box. But I want the list box to already be filled with names from a text. What should I do? I have entirely no knowledge about Visual Basic and I am just watching tutorial from YouTube. I will just use this application so that I can randomly pick names on my online class. Thanks
Jul 26 '20 #1
4 4211
Opening text file in vb6 requires a physical path to the file location.

This code can help you.
Expand|Select|Wrap|Line Numbers
  1. Sub ReadFile(listBox1 As ListBox, filePath As String)
  2.  
  3. Open filePath For Input As #dfile
  4. Dim txt As String
  5.  
  6.   Do While Not EOF(dfile)        ' this will read all text to listbox
  7.    Line Input #dfile, txt  
  8.     listBox1.Items.Add(txt)
  9.   Loop
  10.  
  11.   Close #dfile
  12. End Sub
  13.  
Good luck
Jul 26 '20 #2
It works!!! Thanks a lot, Mate. Really appreciate it!
Jul 26 '20 #3
i was looking for this
thanks alot
Jul 26 '20 #4
You're welcome. Wish you happy coding
Jul 26 '20 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: rogerc | last post by:
My name is Roger. I am very, very new to programming. I hope someone can help me with a problem in VB. I need to copy a text file into an array, the file can very in size, but the strings are...
2
by: lord.tyranus.96 | last post by:
Hi wizards, does somebody know how to read a matlab file with visual basic .net . Thanks in advance.
1
by: vivekgrs | last post by:
hi in the text file iam having the data as mention below.i want 2 retrieve thru vb. 2 34 56 98 245 i want 2 retrive the data individually which is...
0
by: okalpana | last post by:
Hi friends, trying to do a application program.. what is the code to open a existing word document or excel file in Visual Basic 5 with a command button. i.e Clicking th button should open a...
8
by: levi | last post by:
Hallo I have some problems regarding text filtering with Visual Basic. In order to filter only some text lines I want to make a copy of the file as a temporary one, read this copy as a file...
3
by: DGee | last post by:
Hi, this is my first post, so be nice on me! I currently have a program that will input and save into a text file. It stores information on the operations of the program, such as inputs, errors...
0
by: maria80e | last post by:
I called the .js file through visual Basic for Adobe illustrator CS. Its working nice. But some times javascript runtime error occured. But if i run the .js file directly, it does not throws any...
0
by: bdhassan87 | last post by:
how can i insert data to datagrid from text box using visual basic 6.0
13
by: brat33 | last post by:
I am in the process of modifying some code that reads a .txt file after it has been created from .pdf (this works great) and find a specific line in the text file. Once I have found this line (it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.