Re: question(s) about declaring variables



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.

Normally I don't do homework (unless I do)

However the real answer to the underlying questions is that the very
first BASIC came from Dartmouth and had two types of variables

A$ - this is a string
A - this is some sort of a number

Later 'street BASICS' mostly written by Microsoft, invented different
types of numbers % ! # & @ in that sequence

When they ran out of funny characters to stick at the end of a 'name'
they started denigrating the idea of 'suffix designation'

A bit daft
- as they could not see the difference between the wood and the nails


.



Relevant Pages

  • Re: Dont get Array value in textbox
    ... Public Sub UT(ByVal Segment As String, ByVal BD As, ByVal ... though there's little problem with declaring it as a Function. ... USPoPA_NpaNxx = Cells(adrsX, adrsY) ... Dim test As String ...
    (microsoft.public.vb.general.discussion)
  • Re: VB 2008: Option Strict On + Infer On at class level
    ... What does the compiler prevent from declaring x As String? ... Public Sub New ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problem with function
    ... Hence any attempt to write into memory past the end of oldName would ... you are declaring newName inside the ... after oldName so the compiler is not warning you when you overwrite ... If you declare a dummy string just after oldName in your second ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Working with floating point numbers.
    ... Some languages let you do this sort of thing by declaring two variables ... at the same address - e.g. a Double and an 8-byte array of Char. ... S As String * 4 ... Dim S As MyStrings ...
    (microsoft.public.access.modulesdaovba)
  • Local Variables Passing info between classes etc.
    ... which passes it the input a string at a time. ... parseArticleMethod needs to return to get the next line of input, ... Declaring a set or array etc. inside the ParseArticle ... the set or array in the superclass might work, ...
    (comp.lang.java.help)

Loading