By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,928 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,928 IT Pros & Developers. It's quick & easy.

A97 variable length string declaration - how to do?

P: n/a
MLH
I'm working with lots of long strings now, it seems.
I have to import them & parse them constantly. The
A97 memo field type supports only 32768 chars.

What happens when this is processed...
Dim MyString As String
Am I getting VLS declaration or a FLS declaration?
Can I control which I get somehow?

I have done some homework, but I don't understand
my findings. Here's what I read in HELP...

There are two kinds of strings: variable-length and fixed-length
strings.

A variable-length string can contain up to approximately 2
billion (2^31) characters.
A fixed-length string can contain 1 to approximately 64K
(2^16) characters.

But it is not at all clear to me how to declare a variable-length
string VS a fixed-length string.
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
MLH
Testing, it seems that the Dim statement creates a var that will hold
millions of characters. Its not obvious whether Dim MyString As String
differentiates between variable-length strings or fixed-length strings
at the moment of declaring the var.

What is obvious is that the Dim statement creates a string var that
can be assigned string values of any length up to the maximum
handled by variable-length string variables (around 2 billion chars).

I still don't know if A97 allows programmer to specify the string
var type as fixed or variable length?
Nov 13 '05 #2

P: n/a
In article <ue********************************@4ax.com>, MLH
<CR**@NorthState.net> Tue, 6 Sep 2005 11:52:54 writes
Testing, it seems that the Dim statement creates a var that will hold
millions of characters. Its not obvious whether Dim MyString As String
differentiates between variable-length strings or fixed-length strings
at the moment of declaring the var.

What is obvious is that the Dim statement creates a string var that
can be assigned string values of any length up to the maximum
handled by variable-length string variables (around 2 billion chars).

I still don't know if A97 allows programmer to specify the string
var type as fixed or variable length?


Something like (I think)

Dim S As String * 100

I assume the reason why a fixed length string is limited to 64K is that
the length in the Dim statement is implemented as an Integer.
--
Les Desser
(The Reply-to address IS valid)
Nov 13 '05 #3

P: n/a
You can declare a fixed length as:

Dim s As String * 20

However, with modern systems, I can think of NO reason to use fixed length
strings

(about the ONLY exception I can think of is for custom export routines, and
even that is stretching it)

Those fixed length strings are really only there for compatibility with VERY
VERY old BASIC code.

Further, why use a fixed length one? They do NOT run faster, they do NOT
save memory, and really don't do anything for you except let old COBOL
programmers, and few others from 20 years ago work with fixed length string
variables, of which we now don't care about, and don't need.
What happens when this is processed...
Dim MyString As String
Am I getting VLS declaration or a FLS declaration?
You are getting a variable length one.

Can I control which I get somehow?


You can, but do you really need to?

There is a good number of string functions that you can use to pad, or add
spaces.

I mean, just make a handy global function to pad strings. You can use:

Public Function MyPad(s As String, intSize As Integer) As String

MyPad = Format(s, "!" & String(intSize, "@"))

End Function
Now, anywhere in code, you can go:

mypad("abc",20)

The above expression would return the string of "abc", but padded to 20
chars long

So, even for a custom export routine, I don't see the need to declare fixed
length strings.

For input processing, I see even LESS need for fixed length strings.

Perhaps you might expand on why, or what the reasons here are for needing
fixed length strings, but I am at a loss here as why you need a fixed length
variable?

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #4

P: n/a
MLH
Thx to you both. I agree. I don't see any
real need to burden myself dealing with
fixed length strings.

My real concern was whether or not I had
to do anything special to ensure I was dim'ing
string vars correctly (to handle VLS's. Thx!
Nov 13 '05 #5

P: n/a
"MLH" <CR**@NorthState.net> wrote in message
news:ru********************************@4ax.com...
Thx to you both. I agree. I don't see any
real need to burden myself dealing with
fixed length strings.

My real concern was whether or not I had
to do anything special to ensure I was dim'ing
string vars correctly (to handle VLS's. Thx!


On a lot of systems, fixed length strings run a LOT faster! (many times in
fact!!). However, VB or in our case VBA this is NOT the case.

So, your asking about how to use fixed length strings is very often a fair
question. It is a question that I took serous, despite it not having any
bearing in ms-access. So, often as a developer you will want to know if
fixed length variables are available, as they often can run MANY times
faster then VLS.

For some reason, in VB, or VBA, fixed length strings don't seem to change
performance at all, and in fact I seen them slow things down. So, I am
actually of the beliefs that those fixed length strings are "faked" by
ms-access in some fashion, and only put in for compatibility of old basic
code....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.