What's new

Tutorial Load text file text to list using VB6

Status
Not open for further replies.

CodeWarrior

Addict
Joined
Feb 16, 2014
Posts
23
Reaction
16
Points
78
Age
39
This tutorial demonstrate how to load your text file inner text to list

First open notepad and type the following data

Item Loading 1
Item Loading 2
Item Loading 3
Item Loading 4
Item Loading 5
Item Loading 6
Item Loading 7

an save it, save any file name you wan't

Second Open your VB6 and create new project

Add List to the form then copy paste this code

Code:
Option Explicit

Private Sub Form_Load()
   Dim CW As Long
   Dim line As String
   CW = FreeFile
   Open App.Path & "\MyTextFile.txt" For Input As #CW
   Do While Not EOF(CW)
       Line Input #CW, line
       If Len(line) Then List1.AddItem line
   Loop
   Close #CW
End Sub

After that copy or move your create text file and paste inside this project folder.
Now Press F5 to start debuging...

Happy Happy Coding....

This code is credited to ME... :)
 
Status
Not open for further replies.
Back
Top