Re: question(s) about declaring variables
- From: "Steve Easton" <admin@xxxxxxxxxxxxx>
- Date: Mon, 27 Jun 2005 07:29:15 -0400
"J French" <erewhon@xxxxxxxxxx> wrote in message news:42bfc732.92431414@xxxxxxxxxxxxxxxxxxxxxxx
> On Sun, 26 Jun 2005 16:31:16 -0400, "Steve Easton"
> <admin@xxxxxxxxxxxxx> wrote:
>
> >1st. Which is better for a variable that is going to be used for text. Letting a variable be a
> >variant or declaring it as a string. According to MSDN, variants are more "versatile" ( if I'm
> >reading it right. )
>
> The other name for Variants is 'Deviants'
> - avoid them or you'll suffer
>
> >2nd. Why do all code examples use "As String to" declare each variable like this:
> >Dim var1 As String
> >Public var2 As String.
>
> Because that is the new and trendy way of declaring variables
>
> >instead of using the $ type-declaration character like this:
>
> >Dim var1$
> >Public var2 $
>
> You'll find a lot of canny coders still do that
> - even in (the better) examples from MS
>
> >3rd. Why a separate line for each variable
>
> >I realize that declaring them like this:
> >Dim var1, var2, var3 As String
>
> >makes var1 and var2 variants and only var3 is declared as a string.
>
> >when done this way however:
> >
> >Dim var1$, var2$, var3$
>
> >They are all recognized as String variables.
>
> Because there is a Default Type for VB
> - it is historical
> - absurdly the default has migrated over the years from Single, Double
> to Deviant
>
> Stick: DefObj A-Z at the top of /all/ your code and it will save you
> many visits to a tricologist.
>
> >Thus concludes my dumb question(s) for today.
>
> If this is homework, then your teacher is better than most.
Nope, no homework, my last college course was back in the 70's.
My question(s) is/are the result of poking around MSDN and then wondering aloud why you always see
"As String" typed several dozen times when $ does exactly the same thing,
and also the result of poking around my projects using the object browser.
There seems to be a moderate difference of opinion here as to whether using type-declaration
characters is good or bad.
I can understand using "As String" in a published "example" or in shared source code that might be
viewed by people "new" to the language, but in a private project, or a project shared by "more
experienced" programmers, I would think using $ makes much more sense.
--
Steve
95isalive
This site is best viewed............
........................with a computer
.
- Follow-Ups:
- Re: question(s) about declaring variables
- From: Michael C
- Re: question(s) about declaring variables
- From: Bob Butler
- Re: question(s) about declaring variables
- From: Wart
- Re: question(s) about declaring variables
- From: Larry Serflaten
- Re: question(s) about declaring variables
- References:
- question(s) about declaring variables
- From: Steve Easton
- Re: question(s) about declaring variables
- From: J French
- question(s) about declaring variables
- Prev by Date: Run-time error '5' when hiding form
- Next by Date: Re: question(s) about declaring variables
- Previous by thread: Re: question(s) about declaring variables
- Next by thread: Re: question(s) about declaring variables
- Index(es):
Relevant Pages
|