473,224 Members | 1,496 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,224 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 4096
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)
  3. Open filePath For Input As #dfile
  4. Dim txt As String
  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
  11.   Close #dfile
  12. End Sub
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

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...
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.
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...
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...
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...
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...
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...
by: bdhassan87 | last post by:
how can i insert data to datagrid from text box using visual basic 6.0
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...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.