Re: question(s) about declaring variables

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"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


.



Relevant Pages

  • Re: Gernerics Linked List
    ... LinkedList using Generics that stores only one string per node, ... I bet your teacher would appreciate it if you do your homework instead ... newsgroups operate, you will see that accusations of attempted homework ...
    (comp.lang.java.help)
  • Re: Save to hard drive and backup to thumb drive.
    ... Insert a Module in your workbook. ... ByVal lpBuffer As String) As Long ... Public Function HomeWork() ... Dim sStr As String ...
    (microsoft.public.excel.programming)
  • Re: Gernerics Linked List
    ... LinkedList using Generics that stores only one string per node, ... for the entry of a new string (and the creation of a new node), ... I am guessing that you were trying to call a249 an "ass" for encouraging you to do your own homework? ... If you study how these newsgroups operate, you will see that accusations of attempted homework plagiarism are fairly common, and are triggered by a certain demanding, perhaps even haughty tone of posts asking for complete solutions without apparent humility or explanation of effort already expended. ...
    (comp.lang.java.help)
  • Re: Problems with Ada.Text_IO and strings.
    ... "CheGueVerra" writes: ... > is I don't believe I can use external libs for the homework, ... > time if I have a String variable that is declared Well, ... Hint 3: ...
    (comp.lang.ada)
  • Re: String Manipulation
    ... This program iterates through one file and outputs all lines to ... another file which have the word "homework" in them. ... Here is a program which turns a string containing the phrase ... And, finally, a program to remove punctuation from a string: ...
    (comp.lang.python)