Fixed length strings

  • Thread starter Thread starter active
  • Start date Start date
A

active

<VBFixedString(50),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unma
nagedType.ByValTStr, SizeConst:=50)> Public BusinessName As String


txtBusinessName.MaxLength = Len(ludtTmp.BusinessName)



===snip

txtBusinessName is a textbox

Tracking down a problem lead to the above. Maybe it didn't work in VB6 - I'm
not sure.

But now Len returns 0 not 50 as I would like.

I've looked around the doc but can find no way of getting the max length of
the fixed length string

Is it possible??

Cal
 
active said:
<VBFixedString(50),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unma
nagedType.ByValTStr, SizeConst:=50)> Public BusinessName As String


txtBusinessName.MaxLength = Len(ludtTmp.BusinessName)



===snip

txtBusinessName is a textbox

Tracking down a problem lead to the above. Maybe it didn't work in
VB6 - I'm not sure.

But now Len returns 0 not 50 as I would like.

I've looked around the doc but can find no way of getting the max
length of the fixed length string

Is it possible??

Yes, have a look at the code. It doesn't change at run-time. ;-)

Now, serious, maybe you can use reflection (namespace System.Reflection).
The VBFixedString attribute doesn't make the string's length is always 50.
The attribute is only used whenever you use the FilePut/FileGet procedures.
I don't know if there is a kind of Len function that does what you need. I
haven't found one.
 
Now, serious, maybe you can use reflection (namespace System.Reflection).
The VBFixedString attribute doesn't make the string's length is always 50.
The attribute is only used whenever you use the FilePut/FileGet procedures.

I knew that. I just don't know anything about using Reflection and the
examples I looked at do not show me how immediately and I don't want to
digress so I made a set of constants that I use. (Run-on sentence??)

I was hoping someone knew an easy way.

Thanks,
Cal
 
Back
Top