VB6 Conversion. Need help understanding how to implement fixed length string arrays..

  • Thread starter Thread starter Rick Knospler
  • Start date Start date
R

Rick Knospler

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 form data in a fixed length
structure that is written direct to disk.

I need to load the existing files, into a fixed length structure to
initialize the form data within the project.

I am running into problems with statements like the following..

Original vb6 code looked something like:

Type formcfg
'General
CustId As String * 40
CellIdParam(0 To 7) As String * 8
end type

Public c As formcfg

The c structure is loaded with a routine like:

Open File$ For Random As #1 Len = Len(c)
Get #1, 1, c
Close #1

After converting to vb.net I see this code:


'UPGRADE_WARNING: Fixed-length string size must fit in the buffer. Click for
more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"'
<VBFixedString(40),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=41)> Public CustId() As Char

and

'UPGRADE_ISSUE: Declaration type not supported: Array of fixed-length
strings. Click for more:
'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="934BD4FF-1FF9-47BD-888F-D411E47E78FA"'

Dim TestParam(7) As String * 8

How do I recreate the functionallity that I need to work with these saved
structure files that are fixed length..? The fixed length strings have -1
appeneded to the end and therefore increase the size by 1. Is there a way
to handle this type of problem?


Thanks..

-Rick
 
CustId As String * 40
CellIdParam(0 To 7) As String * 8

can change to

<VBFixedString(40)>Dim CustID As String
<VBFixedString(8)> Dim CellIdParam(0 To 7) As String


-----
And
Dim TestParam(7) As String * 8

is

<VBFixedString(8)> Dim TestParam(7) As String

VB.net really doesn't use fixed length strings since it allocates memory,
and in turn resources.

You can get away with....
Dim CustID As String
- or if you need the length
Dim CustID(40) As String

same with:
dim CellIdParam(0 To 7) As String

and
Dim TestParam(7) As String

Hope this helps.
 
Back
Top