UDTs

S

StrandElectric

Hello all

In a vb6 project, which I am trying to rewrite in dot.net, I am reading some
random access files (created long ago in QuickBasic!) where each record
bears a number of data elements. Here is a fragment of code from a module.

Option Explicit
Public FBU As DataBlock1
....

Public Type DataBlock1 ' company master information (FBU)
BusName As String * 30
Address1 As String * 30
Address2 As String * 30
Postcode As String * 6
Tel As String * 20
Fax As String * 20
Email As String * 30
RegForGST As String * 1
ABN As String * 15
GSTPeriod As String * 1
STS As String * 1
OpeningCapital As Currency ' 8
GSTRate As Currency ' 8
CodesAlreadySetFlag As String * 1
Spare1 As String * 54
End Type

This is of course a user defined type which extracts the data fields by
length explicitly. Can anyone point me at the right syntax for dot.net
(specifically Visual Basic Express 2008).

Many thanks
 
O

Onur Güzel

Hello all

In a vb6 project, which I am trying to rewrite in dot.net, I am reading some
random access files (created long ago in QuickBasic!) where each record
bears a number of data elements. Here is a fragment of code from a module..

Option Explicit
Public FBU As DataBlock1
...

Public Type DataBlock1 ' company master information (FBU)
    BusName As String * 30
    Address1 As String * 30
    Address2 As String * 30
    Postcode As String * 6
    Tel As String * 20
    Fax As String * 20
    Email As String * 30
    RegForGST As String * 1
    ABN As String * 15
    GSTPeriod As String * 1
    STS As String * 1
    OpeningCapital As Currency ' 8
    GSTRate As Currency ' 8
    CodesAlreadySetFlag As String * 1
    Spare1 As String * 54
End Type

This is of course a user defined type which extracts the data fields by
length explicitly. Can anyone point me at the right syntax for dot.net
(specifically Visual Basic Express 2008).

Many thanks

Microsoft.VisualBasic.Compatibility.VB6 namespace contains
FixedLengthString class for this purpose:
http://msdn.microsoft.com/en-us/lib...sic.compatibility..vb6.fixedlengthstring.aspx

Just add refernce to Microsoft.VisualBasic.Compatibility.dll assembly.

HTH,

Onur
 
S

StrandElectric

Hello all

In a vb6 project, which I am trying to rewrite in dot.net, I am reading
some
random access files (created long ago in QuickBasic!) where each record
bears a number of data elements. Here is a fragment of code from a module.

Option Explicit
Public FBU As DataBlock1
...

Public Type DataBlock1 ' company master information (FBU)
BusName As String * 30
Address1 As String * 30
Address2 As String * 30
Postcode As String * 6
Tel As String * 20
Fax As String * 20
Email As String * 30
RegForGST As String * 1
ABN As String * 15
GSTPeriod As String * 1
STS As String * 1
OpeningCapital As Currency ' 8
GSTRate As Currency ' 8
CodesAlreadySetFlag As String * 1
Spare1 As String * 54
End Type

This is of course a user defined type which extracts the data fields by
length explicitly. Can anyone point me at the right syntax for dot.net
(specifically Visual Basic Express 2008).

Many thanks

Microsoft.VisualBasic.Compatibility.VB6 namespace contains
FixedLengthString class for this purpose:
http://msdn.microsoft.com/en-us/lib...asic.compatibility.vb6.fixedlengthstring.aspx

Just add refernce to Microsoft.VisualBasic.Compatibility.dll assembly.

HTH,
Onur

Thanks for that Onur. But how to make those fixed length strings out of the
one string that I fetch from the random access file?
 
C

Cor

Another approach

\\\
Dim y As New System.Text.StringBuilder
For i = 0 To 80
y.Append(" ")
Next
Dim z = y.ToString
Mid(z, 1, 30) = "Whatever"
Mid(z, 31, 30) = "WhatElse"
Mid(z, 61, 20) = "TheEnd"
///

Be aware that this punch card emulating way is very legacy

Cor

"StrandElectric" wrote in message
Hello all

In a vb6 project, which I am trying to rewrite in dot.net, I am reading some
random access files (created long ago in QuickBasic!) where each record
bears a number of data elements. Here is a fragment of code from a module.

Option Explicit
Public FBU As DataBlock1
....

Public Type DataBlock1 ' company master information (FBU)
BusName As String * 30
Address1 As String * 30
Address2 As String * 30
Postcode As String * 6
Tel As String * 20
Fax As String * 20
Email As String * 30
RegForGST As String * 1
ABN As String * 15
GSTPeriod As String * 1
STS As String * 1
OpeningCapital As Currency ' 8
GSTRate As Currency ' 8
CodesAlreadySetFlag As String * 1
Spare1 As String * 54
End Type

This is of course a user defined type which extracts the data fields by
length explicitly. Can anyone point me at the right syntax for dot.net
(specifically Visual Basic Express 2008).

Many thanks
 
A

Andrew Morton

StrandElectric said:
In a vb6 project, which I am trying to rewrite in dot.net, I am
reading some random access files (created long ago in QuickBasic!)
where each record bears a number of data elements. Here is a fragment
of code from a module.
This is of course a user defined type which extracts the data fields
by length explicitly. Can anyone point me at the right syntax for
dot.net (specifically Visual Basic Express 2008).

You might find a TextFieldParser helps, although you will probably need
additional processing for the Currency elements.

HTH,

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top