Array of Fixed Length Strings... 
Author Message
 Array of Fixed Length Strings...

Am looking for some help in converting a Type from VB6 over to VB .NET or C#
(doesn't really matter which)....

The original Type:

Type TUser
  Status As Long
  Info As TUserInfo
  From As String * SIZE_USER_FROM
  password As String * SIZE_PASSWORD
  Security(1 To NUM_USER_SECURITY) As String * SIZE_SECURITY_NAME
  Reserved1 As Long
  AllowMultipleLogins As Long
  Reserved2 As Long
  RealName As String * SIZE_USER_NAME
  PhoneNumber As String * SIZE_USER_PHONE
  Company As String * SIZE_USER_ADDRESS
  Address1 As String * SIZE_USER_ADDRESS
  Address2 As String * SIZE_USER_ADDRESS
  City As String * SIZE_USER_ADDRESS
  state As String * SIZE_USER_STATE
  Zip As String * SIZE_USER_ZIP
  Country As String * SIZE_USER_ADDRESS
  Sex As Long
  Editor As Long
  HelpLevel As Long
  Protocol As Long
  TerminalType As Long
  FileDisplay As Long
  MsgDisplay As Long
  PacketType As Long
  LinesPerPage As Long
  HotKeys As Long
  QuoteOnReply As Long
  SortedListings As Long
  PageAvailable As Long
  EraseMorePrompt As Long
  Reserved3 As Long
  Language As String * SIZE_LANGUAGE_NAME
  LastCall As FileTime
  LastNewFiles As FileTime
  ExpireDate As FileTime
  FirstCall As FileTime
  BirthDate As FileTime
  conference As Long
  MsgsWritten As Long
  Uploads As Long
  TotalUploadKbytes As Long
  Downloads As Long
  TotalDownloadKbytes As Long
  DownloadCountToday As Long
  DownloadKbytesToday As Long
  TimesOn As Long
  TimeLeftToday As Long
  MinutesLogged As Long
  SubscriptionBalance As Long
  NetmailBalance As Long
  AccountLockedOut As Long
  PreserveMimeMessages As Long
  ShowEmailHeaders As Long
  Reserved(1 To 36) As Byte
End Type

I have successfully converted everything over with the execption of
"Security"...  Can someone please let me know how I can convert this over?

Your help would be greatly appreciated...

_______________________________________
Mark Bappe
S and T Software



Fri, 13 Aug 2004 06:23:20 GMT  
 Array of Fixed Length Strings...
Structures do not allow you to set an initial size of an array.

When you initialize the structure, you can set the Security item to the size
you wish.

Joe



Quote:
> Am looking for some help in converting a Type from VB6 over to VB .NET or
C#
> (doesn't really matter which)....

> The original Type:

> Type TUser
>   Status As Long
>   Info As TUserInfo
>   From As String * SIZE_USER_FROM
>   password As String * SIZE_PASSWORD
>   Security(1 To NUM_USER_SECURITY) As String * SIZE_SECURITY_NAME
>   Reserved1 As Long
>   AllowMultipleLogins As Long
>   Reserved2 As Long
>   RealName As String * SIZE_USER_NAME
>   PhoneNumber As String * SIZE_USER_PHONE
>   Company As String * SIZE_USER_ADDRESS
>   Address1 As String * SIZE_USER_ADDRESS
>   Address2 As String * SIZE_USER_ADDRESS
>   City As String * SIZE_USER_ADDRESS
>   state As String * SIZE_USER_STATE
>   Zip As String * SIZE_USER_ZIP
>   Country As String * SIZE_USER_ADDRESS
>   Sex As Long
>   Editor As Long
>   HelpLevel As Long
>   Protocol As Long
>   TerminalType As Long
>   FileDisplay As Long
>   MsgDisplay As Long
>   PacketType As Long
>   LinesPerPage As Long
>   HotKeys As Long
>   QuoteOnReply As Long
>   SortedListings As Long
>   PageAvailable As Long
>   EraseMorePrompt As Long
>   Reserved3 As Long
>   Language As String * SIZE_LANGUAGE_NAME
>   LastCall As FileTime
>   LastNewFiles As FileTime
>   ExpireDate As FileTime
>   FirstCall As FileTime
>   BirthDate As FileTime
>   conference As Long
>   MsgsWritten As Long
>   Uploads As Long
>   TotalUploadKbytes As Long
>   Downloads As Long
>   TotalDownloadKbytes As Long
>   DownloadCountToday As Long
>   DownloadKbytesToday As Long
>   TimesOn As Long
>   TimeLeftToday As Long
>   MinutesLogged As Long
>   SubscriptionBalance As Long
>   NetmailBalance As Long
>   AccountLockedOut As Long
>   PreserveMimeMessages As Long
>   ShowEmailHeaders As Long
>   Reserved(1 To 36) As Byte
> End Type

> I have successfully converted everything over with the execption of
> "Security"...  Can someone please let me know how I can convert this over?

> Your help would be greatly appreciated...

> _______________________________________
> Mark Bappe
> S and T Software



Fri, 13 Aug 2004 07:27:26 GMT  
 Array of Fixed Length Strings...
What are you using that for?

I am asking because it matters a lot when designing the type. For example,
if you are passing it to an unmanaged DLL it has to be exact, and thus you
need MarshalAs tags. If you are only using it internally, it should be
redesigned. Something that big really shouldn't be a value type, and fixed
length strings are just asking for trouble.

--
Jonathan Allen



Quote:
> Am looking for some help in converting a Type from VB6 over to VB .NET or
C#
> (doesn't really matter which)....

> The original Type:

> Type TUser
>   Status As Long
>   Info As TUserInfo
>   From As String * SIZE_USER_FROM
>   password As String * SIZE_PASSWORD
>   Security(1 To NUM_USER_SECURITY) As String * SIZE_SECURITY_NAME
>   Reserved1 As Long
>   AllowMultipleLogins As Long
>   Reserved2 As Long
>   RealName As String * SIZE_USER_NAME
>   PhoneNumber As String * SIZE_USER_PHONE
>   Company As String * SIZE_USER_ADDRESS
>   Address1 As String * SIZE_USER_ADDRESS
>   Address2 As String * SIZE_USER_ADDRESS
>   City As String * SIZE_USER_ADDRESS
>   state As String * SIZE_USER_STATE
>   Zip As String * SIZE_USER_ZIP
>   Country As String * SIZE_USER_ADDRESS
>   Sex As Long
>   Editor As Long
>   HelpLevel As Long
>   Protocol As Long
>   TerminalType As Long
>   FileDisplay As Long
>   MsgDisplay As Long
>   PacketType As Long
>   LinesPerPage As Long
>   HotKeys As Long
>   QuoteOnReply As Long
>   SortedListings As Long
>   PageAvailable As Long
>   EraseMorePrompt As Long
>   Reserved3 As Long
>   Language As String * SIZE_LANGUAGE_NAME
>   LastCall As FileTime
>   LastNewFiles As FileTime
>   ExpireDate As FileTime
>   FirstCall As FileTime
>   BirthDate As FileTime
>   conference As Long
>   MsgsWritten As Long
>   Uploads As Long
>   TotalUploadKbytes As Long
>   Downloads As Long
>   TotalDownloadKbytes As Long
>   DownloadCountToday As Long
>   DownloadKbytesToday As Long
>   TimesOn As Long
>   TimeLeftToday As Long
>   MinutesLogged As Long
>   SubscriptionBalance As Long
>   NetmailBalance As Long
>   AccountLockedOut As Long
>   PreserveMimeMessages As Long
>   ShowEmailHeaders As Long
>   Reserved(1 To 36) As Byte
> End Type

> I have successfully converted everything over with the execption of
> "Security"...  Can someone please let me know how I can convert this over?

> Your help would be greatly appreciated...

> _______________________________________
> Mark Bappe
> S and T Software



Fri, 13 Aug 2004 07:28:04 GMT  
 Array of Fixed Length Strings...
Hello Jonathan,
I understand and would change it if I could... This is an unmanaged C++ DLL
from a 3rdparty company and the structures really need to be maintained as
is... This has to be exact...

_______________________________________
Mark Bappe
S and T Software


Quote:
> What are you using that for?

> I am asking because it matters a lot when designing the type. For example,
> if you are passing it to an unmanaged DLL it has to be exact, and thus you
> need MarshalAs tags. If you are only using it internally, it should be
> redesigned. Something that big really shouldn't be a value type, and fixed
> length strings are just asking for trouble.
> > Type TUser
> >   Status As Long
> >   Info As TUserInfo
> >   From As String * SIZE_USER_FROM
> >   password As String * SIZE_PASSWORD
> >   Security(1 To NUM_USER_SECURITY) As String * SIZE_SECURITY_NAME
> >   Reserved1 As Long
> >   AllowMultipleLogins As Long
> >   Reserved2 As Long
> >   RealName As String * SIZE_USER_NAME
> >   PhoneNumber As String * SIZE_USER_PHONE
> >   Company As String * SIZE_USER_ADDRESS
> >   Address1 As String * SIZE_USER_ADDRESS
> >   Address2 As String * SIZE_USER_ADDRESS
> >   City As String * SIZE_USER_ADDRESS
> >   state As String * SIZE_USER_STATE
> >   Zip As String * SIZE_USER_ZIP
> >   Country As String * SIZE_USER_ADDRESS
> >   Sex As Long
> >   Editor As Long
> >   HelpLevel As Long
> >   Protocol As Long
> >   TerminalType As Long
> >   FileDisplay As Long
> >   MsgDisplay As Long
> >   PacketType As Long
> >   LinesPerPage As Long
> >   HotKeys As Long
> >   QuoteOnReply As Long
> >   SortedListings As Long
> >   PageAvailable As Long
> >   EraseMorePrompt As Long
> >   Reserved3 As Long
> >   Language As String * SIZE_LANGUAGE_NAME
> >   LastCall As FileTime
> >   LastNewFiles As FileTime
> >   ExpireDate As FileTime
> >   FirstCall As FileTime
> >   BirthDate As FileTime
> >   conference As Long
> >   MsgsWritten As Long
> >   Uploads As Long
> >   TotalUploadKbytes As Long
> >   Downloads As Long
> >   TotalDownloadKbytes As Long
> >   DownloadCountToday As Long
> >   DownloadKbytesToday As Long
> >   TimesOn As Long
> >   TimeLeftToday As Long
> >   MinutesLogged As Long
> >   SubscriptionBalance As Long
> >   NetmailBalance As Long
> >   AccountLockedOut As Long
> >   PreserveMimeMessages As Long
> >   ShowEmailHeaders As Long
> >   Reserved(1 To 36) As Byte
> > End Type



Fri, 13 Aug 2004 08:12:22 GMT  
 Array of Fixed Length Strings...
Thanks Joe,
I have attempted to do this with the MarshalAs functions for the size of the
string, but still having problems getting all the values from the list?
Would you happen to have an example?

I have tried:

[MarshalAs(UnmanagedType.ByValArray,SizeConst=SIZE_SECURITY_NAME)]

But have problems when you specify that it is an Array that needs to be
returned...

Thanks for the help...

_______________________________________
Mark Bappe
S and T Software


Quote:
> Structures do not allow you to set an initial size of an array.

> When you initialize the structure, you can set the Security item to the
size
> you wish.
> > Type TUser
> >   Status As Long
> >   Info As TUserInfo
> >   From As String * SIZE_USER_FROM
> >   password As String * SIZE_PASSWORD
> >   Security(1 To NUM_USER_SECURITY) As String * SIZE_SECURITY_NAME
> >   Reserved1 As Long
> >   AllowMultipleLogins As Long
> >   Reserved2 As Long
> >   RealName As String * SIZE_USER_NAME
> >   PhoneNumber As String * SIZE_USER_PHONE
> >   Company As String * SIZE_USER_ADDRESS
> >   Address1 As String * SIZE_USER_ADDRESS
> >   Address2 As String * SIZE_USER_ADDRESS
> >   City As String * SIZE_USER_ADDRESS
> >   state As String * SIZE_USER_STATE
> >   Zip As String * SIZE_USER_ZIP
> >   Country As String * SIZE_USER_ADDRESS
> >   Sex As Long
> >   Editor As Long
> >   HelpLevel As Long
> >   Protocol As Long
> >   TerminalType As Long
> >   FileDisplay As Long
> >   MsgDisplay As Long
> >   PacketType As Long
> >   LinesPerPage As Long
> >   HotKeys As Long
> >   QuoteOnReply As Long
> >   SortedListings As Long
> >   PageAvailable As Long
> >   EraseMorePrompt As Long
> >   Reserved3 As Long
> >   Language As String * SIZE_LANGUAGE_NAME
> >   LastCall As FileTime
> >   LastNewFiles As FileTime
> >   ExpireDate As FileTime
> >   FirstCall As FileTime
> >   BirthDate As FileTime
> >   conference As Long
> >   MsgsWritten As Long
> >   Uploads As Long
> >   TotalUploadKbytes As Long
> >   Downloads As Long
> >   TotalDownloadKbytes As Long
> >   DownloadCountToday As Long
> >   DownloadKbytesToday As Long
> >   TimesOn As Long
> >   TimeLeftToday As Long
> >   MinutesLogged As Long
> >   SubscriptionBalance As Long
> >   NetmailBalance As Long
> >   AccountLockedOut As Long
> >   PreserveMimeMessages As Long
> >   ShowEmailHeaders As Long
> >   Reserved(1 To 36) As Byte
> > End Type



Fri, 13 Aug 2004 08:18:42 GMT  
 Array of Fixed Length Strings...
Though I hate to say it, you shouldn't be using VB.Net for this. Instead,
you should use VC++ to act as a proxy between the unmanaged and managed
code.

--
Jonathan Allen



Quote:
> Hello Jonathan,
> I understand and would change it if I could... This is an unmanaged C++
DLL
> from a 3rdparty company and the structures really need to be maintained as
> is... This has to be exact...

> _______________________________________
> Mark Bappe
> S and T Software



> > What are you using that for?

> > I am asking because it matters a lot when designing the type. For
example,
> > if you are passing it to an unmanaged DLL it has to be exact, and thus
you
> > need MarshalAs tags. If you are only using it internally, it should be
> > redesigned. Something that big really shouldn't be a value type, and
fixed
> > length strings are just asking for trouble.



Fri, 13 Aug 2004 09:06:22 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Passing an array of fixed length strings.

2. Passing arrays of fixed length strings.

3. Using fixed-length strings/byte arrays

4. Fixed length strings in a dynamically allocated array

5. Fixed Length String Arrays w/a variable

6. Passing Array of UDT Fixed-Length Strings

7. Copy Memory and Fixed Length String Array!

8. ADOX: Extending a fixed length Jet string field length

9. Passing fixed length string to API and is returning nulls in string

10. Fixed String and Fixed Array

11. ACC97: Fixed-length strings question

12. Fixed length string

 

 
Powered by phpBB® Forum Software