Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have data like this in file.txt
1 50 01-01-2019 12:00:01
2 51 01-01-2019 12:00:01
.
.
.
How can i read this data from
the txt to flixgrid view in vb.net

Note the data in file.txt as
Id stu_no date time

What I have tried:

I need code to help me to fo it
Posted
Updated 14-Jul-19 12:03pm
Comments
Richard MacCutchan 13-Jul-19 10:54am    
What is "flixgrid"?
Mody_2004 13-Jul-19 10:58am    
Its wron.. i means flexgrid it is tool as DataGrid
OriginalGriff 13-Jul-19 10:57am    
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Mody_2004 13-Jul-19 11:01am    
Ok thank u dear .... i understand u
OriginalGriff 13-Jul-19 11:18am    
You're welcome!

BTW: I know it's an "Indian Thing" to use "dear", but you should avoid it on the internet where you don't know who you are talking to. "Dear" can be seen as patronising and offensive - particularly if you are talking to a female. And remember: on the internet, you have no idea what gender you are addressing, so it's best to avoid using it at all. Doesn't bother me, but it will annoy some people.

Take a look at Using OleDb to Import Text Files (tab, CSV, custom)[^]; the code is in C# but converting it to VB.NET should be easy.
 
Share this answer
 
Comments
Maciej Los 14-Jul-19 18:03pm    
5ed!
Alternativelly to solution #1 by Richard MacCutchan[^] solution, you can use:
1. CsvHelper[^]
2. A Fast CSV Reader[^]

You can read all lines from text file and split them by any delimiter using Linq. How?
File.ReadAllLines Method (System.IO) | Microsoft Docs[^]
String.Split Method (System) | Microsoft Docs[^]
Anonymous Types (Visual Basic) | Microsoft Docs[^]

VB.NET
Dim filename As String = "file.txt"
Dim lines As String() = File.ReadAllLines(filename)
Dim data = lines _
	.Select(Function(l) New With _
		{ _
			.Id = l.Split(New String(){" "}, StringSplitOptions.RemoveEmptyEntries)(0), _
			.Stu_no = l.Split(New String(){" "}, StringSplitOptions.RemoveEmptyEntries)(1), _
			.Dt = l.Split(New String(){" "}, StringSplitOptions.RemoveEmptyEntries)(2), _
			.Tm = l.Split(New String(){" "}, StringSplitOptions.RemoveEmptyEntries)(3) _
		}) _
	.ToList()
'TO DO: load data into columns of flexgrid
For Each d In data
	'column(0) = d.Id

Next d

Note: i have never used MSFlexGrid, so you have to change the code to your needs...
 
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