QB45: difference between DIM a$(20) and DIM a(20) AS STRING? 
Author Message
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Hello all,

I'm new to QuickBasic, and am a little puzzled with the various ways
of declaring variables.

For example, what difference, if any, is there between

     DIM a$(20)
     DIM a(20) AS STRING?

And anyway, does it really matter?

Bye and thanks.

--
Harvey Monks



Fri, 21 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?


: Hello all,

: I'm new to QuickBasic, and am a little puzzled with the various ways
: of declaring variables.

: For example, what difference, if any, is there between

:      DIM a$(20)
:      DIM a(20) AS STRING?

: And anyway, does it really matter?

No diff at all...

        Mike



Fri, 21 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:

> Hello all,

> I'm new to QuickBasic, and am a little puzzled with the various ways
> of declaring variables.

> For example, what difference, if any, is there between

>      DIM a$(20)
>      DIM a(20) AS STRING?

As it stands, the second command is only different from the first in one
way.  By defining it as type STRING, it does not need the little dollar
sign, and in fact, you couldn't use it with a() even if you wanted to
after DIMensioning the array AS STRING.

One particular advantage of the second approach is that you can define
fixed lengths for strings.  A fixed-length string can only hold a
certain specified number of characters (letters, numbers, etc.).  By
default, strings are variable-length, which means there is no set limit
and the string length is as large as whatever string you put into it.

To dimension a string so it can hold no more than 10 characters, do
this:

        DIM a AS STRING * 10

You can do the same thing with arrays:

        DIM a(20) AS STRING * 10

Hope this helps.

-Jesse

Quote:

> Bye and thanks.

> --
> Harvey Monks


--
====================================
Very funny Scotty!
Now beam down my clothes!
====================================


Fri, 21 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?


Quote:

>Hello all,

>I'm new to QuickBasic, and am a little puzzled with the various ways
>of declaring variables.

>For example, what difference, if any, is there between

>     DIM a$(20)
>     DIM a(20) AS STRING?

>And anyway, does it really matter?

>Bye and thanks.

>--
>Harvey Monks


both the two statments do the same thing, the '$' sign is a shorthand
way of showing a string. However, if you do the latter line, with
'STRING', then from then on, you dont need to use a $ to reference
your program... ie you could say;
A(10) = "Nice Word"




Fri, 21 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:

>Hello all,
>I'm new to QuickBasic, and am a little puzzled with the various ways
>of declaring variables.
>For example, what difference, if any, is there between
>     DIM a$(20)
>     DIM a(20) AS STRING?
>And anyway, does it really matter?
>Bye and thanks.

"dim a$(20)" and  "dim a(20) as string" are same is use. the only
difference is the suffix "$". i prefer a$(20) cuz this way its easier
to see which variable is a value and which one is a string.
but you are right, that doesnt really matter.
----
Marcos Kreinacke

http://home.pages.de/~crosby

----
Marcos Kreinacke

http://home.pages.de/~crosby



Sun, 23 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:

> >Hello all,

> >I'm new to QuickBasic, and am a little puzzled with the various ways
> >of declaring variables.

> >For example, what difference, if any, is there between

> >     DIM a$(20)
> >     DIM a(20) AS STRING?

> >And anyway, does it really matter?

> >Bye and thanks.

> "dim a$(20)" and  "dim a(20) as string" are same is use. the only
> difference is the suffix "$". i prefer a$(20) cuz this way its easier
> to see which variable is a value and which one is a string.
> but you are right, that doesnt really matter.
> ----
> Marcos Kreinacke

> http://home.pages.de/~crosby

> ----
> Marcos Kreinacke

> http://home.pages.de/~crosby

The AS STRING clause also allows you to define the max length of the string:

DIM a(20) AS STRING * 15

will give you an array of 21 (remember - indexes will go from 0 to 20)
15-character strings.

Tom Lake



Sun, 23 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:


>> For example, what difference, if any, is there between

>>      DIM a$(20)
>>      DIM a(20) AS STRING?

 A() is an array of variable length strings in the second
 and an array of type SINGLE in the first.

Quote:
>As it stands, the second command is only different from the first in one
>way.  By defining it as type STRING, it does not need the little dollar
>sign, and in fact, you couldn't use it with a() even if you wanted to
>after DIMensioning the array AS STRING.

 Yes, you can. You can't use A%(), A!(), A#(), or A&() though, however
 this is a MS-Basic only thing to my knowledge, in any event both
 A() and A$() are legit with the second example and ONLY A$()
 is a string in the first.


Mon, 24 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?


Quote:
>Hello all,

>I'm new to QuickBasic, and am a little puzzled with the various ways
>of declaring variables.

>For example, what difference, if any, is there between

>     DIM a$(20)
>     DIM a(20) AS STRING?

The difference is merely in how you refer to it later.  Example:
        IF A$="Hello, and how are you?" THEN . . .
        IF A="Hello, and how are you?" THEN . . .

You see, it just makes it a little easier to type, not having to type a $.  Other than
that, there is NO difference.

Tony
 . . another satisfied DOS user.
--

"The Russians don't wear underwear"
                           -Abraham Lincoln-
"I never said that about the Chinese"
                           -Mikhael Gorbachev-



Mon, 24 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:

>I'm new to QuickBasic, and am a little puzzled with the various ways
>of declaring variables.
>For example, what difference, if any, is there between
>     DIM a$(20)
>     DIM a(20) AS STRING?
>And anyway, does it really matter?

Hi HM!

1) The first example is a variable length string. It can contain as
many as 32767 characters.

2) Item two is a fixed length string. It is limited to XX characters.
Example:

DIM Text$(25) AS STRING * 80

Try to oput 81 chars into the above Text$(x) and you'll get an error
and/or have a problem.

Fixed length and variable length strings RE handled differently. If
you wanna use less DGROUP space for string variables, then a fixed
length variable might be the thing for you.

If the data could be changing dynamically in length, then variable
length strings are the way to go.

Ep

Ed Parry - Southern California, USA



Mon, 24 May 1999 03:00:00 GMT  
 QB45: difference between DIM a$(20) and DIM a(20) AS STRING?

Quote:


> >Hello all,

> >I'm new to QuickBasic, and am a little puzzled with the various ways
> >of declaring variables.

> >For example, what difference, if any, is there between

> >     DIM a$(20)
> >     DIM a(20) AS STRING?

> The difference is merely in how you refer to it later.  Example:
>         IF A$="Hello, and how are you?" THEN . . .
>         IF A="Hello, and how are you?" THEN . . .

> You see, it just makes it a little easier to type, not having to type a $.  Other than
> that, there is NO difference.

Not quite.  When you dimension an array /variable as STRING, you can
define a fixed length for it.  Example:
        DIM A AS STRING * 10
This sets the length of A to 10, meaning that no more than 10 characters
can be stored in it.

-Jesse

Quote:
> Tony
>  . . another satisfied DOS user.
> --

--
====================================
Very funny Scotty!
Now beam down my clothes!
====================================


Wed, 26 May 1999 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. PC Install from 20/20 software

2. Stateless search from database (Return 20 and 20 records)

3. How to make a sinus output from 20 Hz to 20 KHz

4. Newbie Question: Dim A() as String /Dim A as String()

5. dim string to dim form

6. Online Chats: Week of May 20-24

7. Combining 20+ Tables into One

8. Dividing incoming email into groups of 20

9. calculating Duration1..20

10. Displaying More than 20 Custom Properties

11. Ann: Nebula control library 1.20.1000.0

12. New version of DownloadWunder.net (1.20.1000.1)

 

 
Powered by phpBB® Forum Software