Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Stephen Lebans Code Puzzle

Discussion in 'Information Technology' started by Peter Hibbs, Jul 28, 2006.

  1. Peter Hibbs

    Peter Hibbs
    Expand Collapse
    Guest

    Hi All

    I recently downloaded some code from Stephen Lebans Web site to convert
    Access reports into PDF files (which is brilliant by the way). I noticed that
    the following code snippet is used occasionally :-

    If Len(mUncompressedSnapFile & vbNullString) > 0 Then

    I don't quite understand the reason for the vbNullString in this code, could
    anyone explain it. The variable 'mUncompressedSnapFile' is a normal string
    variable.

    --
    Peter Hibbs
     
  2. Loading...

    Similar Threads Forum Date
    SciTech Stephen Hawking: physics would be 'more interesting' if Higgs boson hadn't been found Breaking News Nov 13, 2013
    Opinion Stephen Hawking: Brain Could Exist Outside Body Breaking News Sep 22, 2013
    SciTech Stephen Hawking: doctors offered to turn off life support 27 years ago Breaking News Jul 30, 2013
    World Stephen Hawking Joins Academic Boycott Of Israel Breaking News May 14, 2013
    SciTech Stephen Hawking: Colonize Space or End the Human Race Breaking News Jan 9, 2012

  3. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    You sure mUncompressedSnapFile is a string, and not a variant?

    When it's possible that a value could be either a zero-length string ("") or
    Null, it's more efficient to use

    If Len(mUncompressedSnapFile & vbNullString) > 0 Then

    than

    If Not IsNull(mUncompressedSnapFile) Then
    If Len(mUncompressedSnapFile) > 0 Then

    or

    If Not IsNull(mUncompressedSnapFile) Then
    If mUncompressedSnapFile <> "" Then

    In other words, what Stephen's doing there is making sure that
    mUncompressedSnapFile contains a non-blank string.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message
    news:59E4A3FA-2027-485C-800E-D45D69A775B1@microsoft.com...
    > Hi All
    >
    > I recently downloaded some code from Stephen Lebans Web site to convert
    > Access reports into PDF files (which is brilliant by the way). I noticed
    > that
    > the following code snippet is used occasionally :-
    >
    > If Len(mUncompressedSnapFile & vbNullString) > 0 Then
    >
    > I don't quite understand the reason for the vbNullString in this code,
    > could
    > anyone explain it. The variable 'mUncompressedSnapFile' is a normal string
    > variable.
    >
    > --
    > Peter Hibbs
     
  4. Terry Kreft

    Terry Kreft
    Expand Collapse
    Guest

    I'm guessing that originally Stephen declared it as a variant.

    --

    Terry Kreft


    "Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message
    news:59E4A3FA-2027-485C-800E-D45D69A775B1@microsoft.com...
    > Hi All
    >
    > I recently downloaded some code from Stephen Lebans Web site to convert
    > Access reports into PDF files (which is brilliant by the way). I noticed

    that
    > the following code snippet is used occasionally :-
    >
    > If Len(mUncompressedSnapFile & vbNullString) > 0 Then
    >
    > I don't quite understand the reason for the vbNullString in this code,

    could
    > anyone explain it. The variable 'mUncompressedSnapFile' is a normal string
    > variable.
    >
    > --
    > Peter Hibbs
     
  5. Peter Hibbs

    Peter Hibbs
    Expand Collapse
    Guest

    Hi Douglas and Terry

    The variable in question is definitely declared as a String, however,
    looking through the rest of the code I notice that this method is also used
    against values that are passed as in-line variables in Functions which could
    be Null values (maybe). Perhaps Stephen always uses the same technque for
    checking a zero length string without worrying about what type of variable it
    is.

    Anyway, thanks for the information.

    --
    Peter Hibbs
     
  6. Stephen Lebans

    Stephen Lebans
    Expand Collapse
    Guest

    Michael Kaplan told me this was the most efficient method to check for a
    zero length string. I've been doing it ever since.

    --

    HTH
    Stephen Lebans
    http://www.lebans.com
    Access Code, Tips and Tricks
    Please respond only to the newsgroups so everyone can benefit.


    "Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message
    news:8DB38BC9-7E8F-423C-9CF6-978B2CA89582@microsoft.com...
    > Hi Douglas and Terry
    >
    > The variable in question is definitely declared as a String, however,
    > looking through the rest of the code I notice that this method is also
    > used
    > against values that are passed as in-line variables in Functions which
    > could
    > be Null values (maybe). Perhaps Stephen always uses the same technque for
    > checking a zero length string without worrying about what type of variable
    > it
    > is.
    >
    > Anyway, thanks for the information.
    >
    > --
    > Peter Hibbs
    >
     
  7. Terry Kreft

    Terry Kreft
    Expand Collapse
    Guest

    Yes, I can see that as
    "" & vbNullString = vbNullString

    and there has been a long discusion elsewhere as to why testing for
    Len(vbNullString) is more efficient than testing for Len("").


    --

    Terry Kreft


    "Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>
    wrote in message news:u5XvhfLmGHA.2056@TK2MSFTNGP03.phx.gbl...
    > Michael Kaplan told me this was the most efficient method to check for a
    > zero length string. I've been doing it ever since.
    >
    > --
    >
    > HTH
    > Stephen Lebans
    > http://www.lebans.com
    > Access Code, Tips and Tricks
    > Please respond only to the newsgroups so everyone can benefit.
    >
    >
    > "Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message
    > news:8DB38BC9-7E8F-423C-9CF6-978B2CA89582@microsoft.com...
    > > Hi Douglas and Terry
    > >
    > > The variable in question is definitely declared as a String, however,
    > > looking through the rest of the code I notice that this method is also
    > > used
    > > against values that are passed as in-line variables in Functions which
    > > could
    > > be Null values (maybe). Perhaps Stephen always uses the same technque

    for
    > > checking a zero length string without worrying about what type of

    variable
    > > it
    > > is.
    > >
    > > Anyway, thanks for the information.
    > >
    > > --
    > > Peter Hibbs
    > >

    >
    >
     
  8. Terry Kreft

    Terry Kreft
    Expand Collapse
    Guest

    I know, my statement was that "_originally_ Stephen ...".

    Anyway Stephens replied elswhere.

    --

    Terry Kreft


    "Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message
    news:8DB38BC9-7E8F-423C-9CF6-978B2CA89582@microsoft.com...
    > Hi Douglas and Terry
    >
    > The variable in question is definitely declared as a String, however,
    > looking through the rest of the code I notice that this method is also

    used
    > against values that are passed as in-line variables in Functions which

    could
    > be Null values (maybe). Perhaps Stephen always uses the same technque for
    > checking a zero length string without worrying about what type of variable

    it
    > is.
    >
    > Anyway, thanks for the information.
    >
    > --
    > Peter Hibbs
    >
     

Share This Page