Fixed length strings

L

Lost

Are fixed length strings available in VB.Net?

In Quickbasic, fixed length strings could be declared thus:

DIM str AS STRING * 10 'gives a string of length 10

Is there some equivalent command in VB.Net Express?
 
H

Herfried K. Wagner [MVP]

Lost said:
Are fixed length strings available in VB.Net?

Yes and no. Could you describe the scenario in more detail? Maybe there is
a better solution than a fixed-length string.
 
J

J. Moreno

Lost said:
Are fixed length strings available in VB.Net?

In Quickbasic, fixed length strings could be declared thus:

DIM str AS STRING * 10 'gives a string of length 10

Is there some equivalent command in VB.Net Express?

There's no equivalent, but it's trivially easy to limit either the value
assigned to a variable, or the result of "reading" from a variable.

Show some code and someone will probaby have a more detailed suggestion.
 
L

Lost

J. Moreno said:
There's no equivalent, but it's trivially easy to limit either the value
assigned to a variable, or the result of "reading" from a variable.

That's what I've done as a workaround.

Thanks to everyone who answered.
 
H

HKSHK

Hello Lost,
Are fixed length strings available in VB.Net?

There is.

<VBFixedString(YourStringLength)>

Taken from http://msdn2.microsoft.com/en-us/library/x14b6s77.aspx


Structure Person
Public ID As Integer
Public MonthlySalary As Decimal
Public LastReviewDate As Long
<VBFixedString(15)> Public FirstName As String
<VBFixedString(15)> Public LastName As String
<VBFixedString(15)> Public Title As String
<VBFixedString(150)> Public ReviewComments As String
End Structure

Best Regards,

HKSHK
 
L

Lost

HKSHK said:
Hello Lost,


There is.

<VBFixedString(YourStringLength)>

Taken from http://msdn2.microsoft.com/en-us/library/x14b6s77.aspx


Structure Person
Public ID As Integer
Public MonthlySalary As Decimal
Public LastReviewDate As Long
<VBFixedString(15)> Public FirstName As String
<VBFixedString(15)> Public LastName As String
<VBFixedString(15)> Public Title As String
<VBFixedString(150)> Public ReviewComments As String
End Structure

Thank you.
 

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