473,406 Members | 2,217 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,406 software developers and data experts.

Writing fixed length files

VB6 allowed you to define User types that you could write to file using the
[Put] statement. This is a nice way to generate fixed length text files. See
Below.
How do you do this in VB.NET?
Thanks,
Ken
============
Code Snipit
============
Private Type DAlloc
Code As String * 1
Amount As String * 10
Filler As String * 2
End Type

Dim Debit As DAlloc
Dim i as Integer
Dim iOutFile as Integer

iOutFile = FreeFile
Open msOutFile For Random As #iOutFile Len = Len(Debit)
Debit.Filler = VbCr
For i = 1 To 5
Debit.Code = i
Debit.Amount = CStr(i *2)
Put #iOutFile, , Debit
Next
============

Nov 22 '05 #1
1 4588
Klomax,

When there is the streamwriter class to your possesion why than use a method
which seems to come from the times of CP/m

http://msdn.microsoft.com/library/de...classtopic.asp

Did you know that there are the newsgroups
microsoft.public.dotnet.languages.vb
and/or
microsoft.public.dotnet.languages.vb.upgrade

In my opinion better for your question, however feel free in what newsgroup
you ask your questions. (The first one is one of the most active dotNet
developper newsgroups)

I hope this helps?

Cor

"KLomax" <KL****@discussions.microsoft.com>
VB6 allowed you to define User types that you could write to file using
the
[Put] statement. This is a nice way to generate fixed length text files.
See
Below.
How do you do this in VB.NET?
Thanks,
Ken
============
Code Snipit
============
Private Type DAlloc
Code As String * 1
Amount As String * 10
Filler As String * 2
End Type

Dim Debit As DAlloc
Dim i as Integer
Dim iOutFile as Integer

iOutFile = FreeFile
Open msOutFile For Random As #iOutFile Len = Len(Debit)
Debit.Filler = VbCr
For i = 1 To 5
Debit.Code = i
Debit.Amount = CStr(i *2)
Put #iOutFile, , Debit
Next
============

Nov 22 '05 #2

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

Similar topics

4
by: Thierry Lam | last post by:
Let's say I already wrote a file and have the following: testing testing testing testing testing testing Is there an easy way to write something of variable length at the top of the file? ...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
3
by: ecov | last post by:
Is there any easy way to read into a dataset a file that was created from a BCP command. The file is in a fixed length format. I would also like to be able to write out a dataset to the same type...
3
by: KLomax | last post by:
VB6 allowed you to define User types that you could write to file using the statement. This is a nice way to generate fixed length text files. See Below. VB.NET does not support UserTypes with...
3
by: Marco Herrn | last post by:
Hi, I have a text file with some lines in it. Now I want to iterate over this file and exchange some lines with some others. I tried this approach: try: myfile= file('myfile', 'r+') while...
15
by: Tommy B | last post by:
I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. See, I'd have a file like: Tommy 555 Bob 62 Joe 529 And I'd want to set it to be:...
4
by: John | last post by:
I can create text file, but how can I create a text file where the values are at the same location on every line? I want to define the location where the values starts and define the length of...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
1
by: kendrick82 | last post by:
Hi, I would like to seek some advise and assistance regarding the following matter as I am new to VB.Net. I'll appreciate any helps render. I am developing a VB application using VB.Net 2003 to...
4
by: Jeff | last post by:
Hey I'm wondering how the Fixed-Width Text Format is What I know is that the top line in this text format will contain column names. and each row beneath the top line represent for example a...
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.