September 27th, 2012, 08:31 AM
how to create a fixed limit String in VB? In previous versions, it was:
Dim Name As String * 10 (length of 10 characters)
But now I'm using VB2012 and it doesn't work.
Thanks for a reply.
September 28th, 2012, 02:02 AM
I can't think of any valid reason to use fixed length strings in modern systems. That does not have any performance boost either.
September 28th, 2012, 12:20 PM
In older VB I used them was when writing to or reading from fixed length files (or when dealing with binary files but that purpose is obsolete now). Also when making API calls. Haven't needed them lately.
Originally Posted by debasisdas
There is the VBFixedStringAttribute Class which treats a string as if it were fixed, but is not really a fixed string.
“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
September 29th, 2012, 11:49 AM
When dealing with calls that require a fixed length buffer, I use a string filled with Null characters (Chr$(0)). For example, to read in a binary file:
FileNum = OpenFile(FileName, 5, 0, 80)
strBuffer = String$(LOF(FileNum), Chr$(0))
Get #FileNum, , strBuffer