Re: Avoidinig globals

From: Phill. W (P.A.Ward_at_o-p-e-n-.-a-c-.-u-k)
Date: 03/08/05


Date: Tue, 8 Mar 2005 11:17:04 -0000


"Tim" <al@gahnstrom.se> wrote in message
news:MC2Xd.19099$d5.146369@newsb.telia.net...
> I mean that if I forget to dim a a local variable but there is already
> such a variable in the global scope then my function will use the
> global variable without me intending it too.

Welcome to the World of Naming Conventions.

There are those who sneer at prefixes of /any/ kind on variable
names, because they know (or, rather, their mega-expensive
IDE tells them) what DataType a variable is and whether it's
Private, Public, Global or whatever.

Those of us in the Real World, who still have to fight the Good
Fight [occasionally] with the likes of Notepad prefer to be able
to read this kind of thing for ourselves.

At the /very/ least, include a "Scope" prefix on your variable names,
as in

iCount ' [local] Integer variable
smCount ' String Variable [at *M*odule (or class) level]
lgCount ' Long variable [*G*lobal]

That way, you /can't/ get your variables mixed up.

HTH,
    Phill W.



Relevant Pages

  • Re: Clipboard Problem
    ... Tim Williams ... message is in html format not rich text or plain text. ... Dim MyDataObj As DataObject ... Public Function GetOffClipboard() As Variant ...
    (microsoft.public.excel.programming)
  • Re: Larry Holmes questions
    ... Why do people regard his fight with Tim Witherspoon as being close. ... Why was there no Holmes vs Norton II? ... Larry hurt in round nine. ...
    (rec.sport.boxing)
  • Re: ADO Recordset.Filter in Excel 2002
    ... Tim ... Dim RS As ADODB.Recordset ... Dim oRS As ADODB.Recordset ... 'Populate the Recordset object with a SQL query ...
    (microsoft.public.excel.programming)
  • Re: Get Excel Value
    ... > Hi Tim ... > You need to create an instance of Excel, open the required workbook file, ... > Dim rs As DAO.Recordset ... > Graham Mandeno ...
    (microsoft.public.access.modulesdaovba)
  • Re: UPDATE sql statement
    ... Thanks Tim but the ADODB.Recordset object is not recognised and I get an ... > Sub Tester() ... > Dim lngRecs As Long ...
    (microsoft.public.excel.programming)