Solved

Variable Length Strings -- Format of Extra 10 Bytes

Posted on 2002-04-24
7
177 Views
Last Modified: 2010-05-02
When using variable length strings (which is a GOOD thing), what is the format for the extra 10 bytes that are used?
0
Comment
Question by:GivenRandy
  • 3
  • 2
  • 2
7 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 6966007
Is this what you are after?

http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=30

Gives description of internal storage of strings in memory
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6966192
Azra, that's interesting.  It appears that the second page has the relevant information.

Here's some string information:

Fixed-length strings are good if you know the exact size of the data to be saved, and will usually run much faster than a variable length string of th same size.

Variable length strings have a certain amount of overhead in order to know how much data is in the string.

A string constant may have a direct memory reference (in-line reference) or it may have an indirect memory reference (address pointer to where the string is found.)

--
Variable length string will usually have the indirect memory pointer, meaning that their structure usually consists of a few bytes indicating the length of the file, then an address indicating where the text is located.  To view the actual data, you need to follow the address and look for the specified number of bytes (maybe minus one.)

>what is the format for the extra 10 bytes
I haven't looked lately at the details, but hopefully the above is enough info for you.
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 6967513
Not really sure if it answers it (I might have missed the answer in there). I figured there were about 4 bytes for length, 4 bytes for memory address, 2 for something else. Was looking for the layout of that. Was that in there?

I try to use variable-length strings unless absolutely required (but other options are usually better). VB.NET drops fixed-length strings.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 28

Expert Comment

by:AzraSound
ID: 6967778
The figure on Page 2 seems to summarize it in its caption:

"The LenB function returns the value of the double word that immediately precedes the first character. The Dim x As String statement reserves 4 bytes for the descriptor, but no memory is allocated for the string until the first assignment occurs."

So, to me, that says:

8 bytes =
4 bytes for the double word telling length of string +
4 bytes for the descriptor
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6967779
I'm not sure where those other 2 bytes you are referring to are coming from.  Are you sure it is 10 bytes?
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 6968268
For storage size, online help says "10 bytes + string length" for variable-length strings.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6969107
I thought that a user-defined type might give me a clue:

Private Type x
  s As String
End Type

Private Sub Command2_Click()
  Dim y As x
  y.s = String$(65534, "q")
  Open "C:\qaz.txt" For Binary As #1
  Put #1, , y
  Close 1
End Sub

The output file contains a leading hex sequence of 2 bytes for strings less than 65535, and 6 bytes for strings of 65535 or more (64K - 1)

I suspect that the extra two bytes is used to differentiate between a "near pointer" and a "far pointer."
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now