From what I understand the VBFixedString
attribute is only recognised by certain file based methods to help structure content written to/read from files. The compiler will not use that attribute for anything else, including to alter how a variable assignment is compiled.
Taken from MSDN:
The VBFixedStringAttribute is informational and cannot be used to
convert a variable length string to a fixed string. The purpose of
this attribute is to modify how strings in structures and non-local
variables are used by methods or API calls that recognize the
VBFixedStringAttribute. Keep in mind that this attribute does not
change the actual length of the string itself.
The last sentence is the important bit:
Keep in mind that this attribute does not change the actual length of the string itself.
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.vbfixedstringattribute.aspx
EDIT 1:
A quick example on how to auto-padding a string based on a fixed length:
Function FixedLengthString(ByVal value As String, ByVal totalLength As Integer, ByVal padding As Char) As String
Dim length = value.Length
If (length > totalLength) Then Return value.Substring(0, totalLength)
Return value.PadRight(totalLength, padding)
End Function
Here you can pass in a string and if the length of the string is greater than the specified total length you will get a string matching that length. Anything less and you'll get the string plus the padding character upto the specified total length.
This can be improved with error checking and maybe making the method an extension method so you don't have to pass "value".