473,385 Members | 1,645 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,385 software developers and data experts.

Reading fields from records in vb.net

Suppose I 've got a file in which each record contains 3 fields delimited by
blanks. I want to loop through the file and read each record into a
structure containing three corresponding fields. How would I do that in
vb.net? Thanks...

Dan
Nov 21 '05 #1
2 1316
"DanC" <Da**@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Suppose I 've got a file in which each record contains 3 fields delimited
by blanks. I want to loop through the file and read each record into a
structure containing three corresponding fields.


Something like this?

Dim reader As New StreamReader( "file" )
Dim sLine as String = reader.ReadLine()

Do While Not ( sLine Is Nothing )
Dim sFields As String() = sLine.Split( " "c )

strukture.Field1 = sFields( 0 )
strukture.Field2 = sFields( 1 )
strukture.Field3 = sFields( 2 )
Loop

reader.Close()

HTH,
Phill W.
Nov 21 '05 #2
Thanks Phil. Is that the most efficient way to do it? Is there a way to
read the record fields directly into the structure?

Dan

"Phill. W" wrote:
"DanC" <Da**@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Suppose I 've got a file in which each record contains 3 fields delimited
by blanks. I want to loop through the file and read each record into a
structure containing three corresponding fields.


Something like this?

Dim reader As New StreamReader( "file" )
Dim sLine as String = reader.ReadLine()

Do While Not ( sLine Is Nothing )
Dim sFields As String() = sLine.Split( " "c )

strukture.Field1 = sFields( 0 )
strukture.Field2 = sFields( 1 )
strukture.Field3 = sFields( 2 )
Loop

reader.Close()

HTH,
Phill W.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stuart Mueller | last post by:
I have a mySQL database, called clients it has a single table called client with 2325 records in it. It was originally an Access database but I have exported it to mySQL. I have created a system...
6
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
2
by: Miguelito Bain | last post by:
hi everyone- i inheritrd a database that wasn't designed very well. i'm trying to decide whether or not it is a good idea to add at least 8 more fields to a table that already has existing...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
16
by: Roy | last post by:
I use a Access 2K application.I am trying to use Chuck Grimsby(clsReadTextFile.txt)class utility to read a text file and then do a import of the same into my database.The question is how to call...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
4
by: Jason | last post by:
Could anyone spare some time and try to help me out. I've got a .txt data file with a name, pin, balance seperated by commas. I am opening the file and using Split to split it between the ,'s I...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
4
by: ducttape | last post by:
Hi, I have been trying for several days to read XML files into my program. I have been following several good tutorials on the internet, but I am struggling because the particular XML files that I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.