Fixed length strings

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
 
A

Armin Zingler

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.
 
A

active

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
 

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