string decleration 
Author Message
 string decleration

What does this deceleration mean

Dim NAME As String * 1024

Thanx



Wed, 25 Aug 2004 02:06:58 GMT  
 string decleration
It is allocating 1024 bytes of memory for a fixed-length string variable.


Quote:
> What does this deceleration mean

> Dim NAME As String * 1024

> Thanx



Wed, 25 Aug 2004 01:24:58 GMT  
 string decleration
Steve's reply is correct; I just wanted to elaborate on it:

Dim s As String

This makes a string variable called s which can contain a string of any
length from zero to approximately 2 GB.  The size of the string depends on
what you assign to it, or how you chop it up with left$() right$() and
mid$() and trim$() and stuff.

Dim s As String * [some number]

This declares a string called s which will *always* be [some number] in
size.  for example,

Dim sName As String * 10
sName = "Mike Labosh"

contains "Mike Labos" because the string can only be 10 bytes long, as per
the declaration.

Dim sName As String * 10
sName = "Mike"

contains "Mike      " because the string will always be 10 bytes long as per
the declaration.  the system will pad a string with space characters when
it's not long enough to fill the fixed length variable.

While we're at it, there are some functions LSet and RSet which will justify
the text in a fixed length string to either the left or the right end of the
space padding.  This is sometimes useful for doing columned printouts in a
fixed-width font.  Try to avoid this when doing database work.  Text /
string fields in databases prefer to store without padding, even though you
may be tempted to "Dim sFirstName As String * 20" just because the database
field is called FirstName and is a 20 byte text field.

--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei



Wed, 25 Aug 2004 02:54:28 GMT  
 string decleration
By the by,
    I have read fixed length strings will not be *directly* supported in
VB.net and should be avoided if you are planning on converting this app to
.net

:o)



Wed, 25 Aug 2004 03:15:14 GMT  
 string decleration
Interesting.  I don't use them anyways because hardcoding the length of a
string is a maintenence hassle.  but thanks for the heads-up.

--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei



Wed, 25 Aug 2004 03:34:40 GMT  
 string decleration

Quote:
>     I have read fixed length strings will not be *directly* supported in
> VB.net and should be avoided if you are planning on converting this app to
> .net

And if you are planning on upgrading **any** existing project of yours, then...

http://www.devx.com/free/hotlinks/2002/ednote022002/ednote022002.asp

Rick



Wed, 25 Aug 2004 08:53:14 GMT  
 string decleration
Seems kind of strange because fixed length strings have existed in the Basic
World since GWBasic.


Quote:
> By the by,
>     I have read fixed length strings will not be *directly* supported in
> VB.net and should be avoided if you are planning on converting this app to
> .net

> :o)



Sat, 04 Sep 2004 12:55:04 GMT  
 string decleration
On Tue, 19 Mar 2002 04:55:04 GMT, "Mike Miller"

Quote:

>Seems kind of strange because fixed length strings have existed in the Basic
>World since GWBasic.

I don't recall them before UDTs appeared.
Quote:



>> By the by,
>>     I have read fixed length strings will not be *directly* supported in
>> VB.net and should be avoided if you are planning on converting this app to
>> .net

>> :o)



Sat, 04 Sep 2004 17:37:46 GMT  
 string decleration

Quote:
> >Seems kind of strange because fixed length strings have existed in the
Basic
> >World since GWBasic.
> I don't recall them before UDTs appeared.

Yes, what about UDT's???
Will it not be possible to use udt's containing fixed length string?
/Peo


Sat, 04 Sep 2004 18:19:51 GMT  
 string decleration


Quote:
> On Tue, 19 Mar 2002 04:55:04 GMT, "Mike Miller"

> >Seems kind of strange because fixed length strings have existed in the
Basic
> >World since GWBasic.
> I don't recall them before UDTs appeared.

I don't know when UDTs first appeared, but fixed length strings certainly
existed in GWBasic. Without their existence, I don't know how one would have
defined random files with fixed-length records. In this regard, I guess
Field statements were the predecessor of the UDT.


Sat, 04 Sep 2004 20:41:16 GMT  
 string decleration
On Tue, 19 Mar 2002 12:41:16 GMT, "Hugh Laderman"

Quote:



>> On Tue, 19 Mar 2002 04:55:04 GMT, "Mike Miller"

>> >Seems kind of strange because fixed length strings have existed in the
>Basic
>> >World since GWBasic.
>> I don't recall them before UDTs appeared.

>I don't know when UDTs first appeared, but fixed length strings certainly
>existed in GWBasic. Without their existence, I don't know how one would have
>defined random files with fixed-length records. In this regard, I guess
>Field statements were the predecessor of the UDT.

Well yes and no there - I considered Field statements before posting
that - and would not really define them as Fixed Length Strings

If you made an assignment to a Fielded string - its length would
change and you would lose the 'mapping' on to the file record.

A true fixed lenght string would 'retain' its length even after say:
     A$ = "Test"

- Show quoted text -



Sat, 04 Sep 2004 22:47:16 GMT  
 string decleration


Quote:
> Well yes and no there - I considered Field statements before posting
> that - and would not really define them as Fixed Length Strings

> If you made an assignment to a Fielded string - its length would
> change and you would lose the 'mapping' on to the file record.

> A true fixed lenght string would 'retain' its length even after say:
>      A$ = "Test"

Yes, that's true. I guess there was never considered to be a good reason
(with the exception of file support) to use fixed length strings. Is there
now ?


Sat, 04 Sep 2004 23:29:27 GMT  
 string decleration

Quote:

> On Tue, 19 Mar 2002 12:41:16 GMT, "Hugh Laderman"



> >> On Tue, 19 Mar 2002 04:55:04 GMT, "Mike Miller"

> >> >Seems kind of strange because fixed length strings have existed in the
> >Basic
> >> >World since GWBasic.
> >> I don't recall them before UDTs appeared.

> >I don't know when UDTs first appeared, but fixed length strings certainly
> >existed in GWBasic. Without their existence, I don't know how one would have
> >defined random files with fixed-length records. In this regard, I guess
> >Field statements were the predecessor of the UDT.
> Well yes and no there - I considered Field statements before posting
> that - and would not really define them as Fixed Length Strings

> If you made an assignment to a Fielded string - its length would
> change and you would lose the 'mapping' on to the file record.

> A true fixed lenght string would 'retain' its length even after say:
>      A$ = "Test"

From PWB (remember that? <G>) from PB7.1 and I recall (I think,
correctly) from well before this but I don't have prior versions still
handy for referral...

_ STRING      A string variable in a COMMON, DIM, REDIM, SHARED,
              or STATIC statement. If STRING is followed by n, the
              string has a fixed length of n bytes. If STRING is not
              followed by n, the string is variable-length.

Certainly other flavors of Basic I've used also had fixed length strings
as that was one mode used to share data w/fortran and/or C via COMMMON.
Actually, I'm not thinking I can recall a version I've used that didn't
have fixed length strings...



Sun, 05 Sep 2004 00:17:28 GMT  
 string decleration
On Tue, 19 Mar 2002 15:29:27 GMT, "Hugh Laderman"

Quote:



>> Well yes and no there - I considered Field statements before posting
>> that - and would not really define them as Fixed Length Strings

>> If you made an assignment to a Fielded string - its length would
>> change and you would lose the 'mapping' on to the file record.

>> A true fixed lenght string would 'retain' its length even after say:
>>      A$ = "Test"

>Yes, that's true. I guess there was never considered to be a good reason
>(with the exception of file support) to use fixed length strings. Is there
>now ?

Yup - sending Structures to APIs
- apart from some dirty tricks to obtain 'unions' using LSet

- Show quoted text -



Sun, 05 Sep 2004 00:22:30 GMT  
 string decleration


Quote:
> On Tue, 19 Mar 2002 15:29:27 GMT, "Hugh Laderman"



> >> Well yes and no there - I considered Field statements before posting
> >> that - and would not really define them as Fixed Length Strings

> >> If you made an assignment to a Fielded string - its length would
> >> change and you would lose the 'mapping' on to the file record.

> >> A true fixed lenght string would 'retain' its length even after say:
> >>      A$ = "Test"

> >Yes, that's true. I guess there was never considered to be a good reason
> >(with the exception of file support) to use fixed length strings. Is
there
> >now ?

> Yup - sending Structures to APIs
> - apart from some dirty tricks to obtain 'unions' using LSet

Yeah, but that's kinda the same thing as file support, i.e. formatted for
the requirements of some other program. Is there any reason to use it solely
within a single program ?


Sun, 05 Sep 2004 00:51:18 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Global Class Decleration

2. Type decleration

3. mapi decleration in vb4

4. Global Decleration - Problem.

5. sophisticated decleration

6. Decleration Problem - Urgent

7. SendInput Decleration

8. Need decleration listview LVM_GETITEMRECT

9. String to Array and Array to String

10. REPLACING STRINGS WITH STRINGS

11. Immediate Problem: Replacing string within a string through a field

12. String.Trim and String.TrimEnd behave irrationally!

 

 
Powered by phpBB® Forum Software