equivilant declaration in vb .net? (from vb6 sample)

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
I think this is it: (added this)

<VBFixedString(MAX_PATH),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst:=MAX_PATH)>
Public cFileName As String

<VBFixedString(14),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr,SizeConst:=14)>
Public cAlternate As String
 
I think this is it: (added this)

<VBFixedString(MAX_PATH),System.Runtime.InteropServices.MarshalAs(System.Run
time.InteropServices.UnmanagedType.ByValTStr,SizeConst:=MAX_PATH)>
Public cFileName As String

<VBFixedString(14),System.Runtime.InteropServices.MarshalAs(System.Runtime.I
nteropServices.UnmanagedType.ByValTStr,SizeConst:=14)>
Public cAlternate As String

Is this recommended practice or are you better off handling/enforcing
fixed-width strings through code? It seems to me like this is just a
backwards-compatibility thing.
 
* "news.microsoft.com said:
public cFileName As String * MAX_PATH
public cAlternate As String * 14

Have a look at the docs for the 'VBFixedStringAttribute' class.
 
I wouldn't normally use fixed-length strings, but I was calling a
win32 api and it required that (in the vb6 code), so I was carrying it
over to .net.

Scott
 
Back
Top