Click here to Skip to main content
15,886,593 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have a text file whose entries are as

Alan
Priya
Niva
Zia
.
.
.
.


I want to show these on a form in data grid.Plz tell how can i assign these one by one value in the cells of the data grid.
Posted
Comments
CHill60 15-Jan-15 6:49am    
What have you tried?

1 solution

Something like this should work
VB
Dim f As Integer
f = FreeFile
Open "c:\temp\myFile.txt" For Input As #f

Dim col As Integer, row As Integer
col = 1
row = 1

Dim text_to_enter As String
Do Until EOF(f)
	Input #f, text_to_enter
	MSFlexGrid1.TextMatrix(row, col) = text_to_enter
	row = row + 1  
        'or however you are deciding which column/row to enter the data into
Loop
Close #f

Warning - I don't have VB6 any more so I haven't been able to test this

Some references that might help:
Using the FlexGrid control[^]
Reading Simple Text Files[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900