+ Reply to Thread
Results 1 to 3 of 3

Question about VB constants

  1. #1
    Registered User
    Join Date
    07-28-2005
    Posts
    9

    Exclamation Question about VB constants

    I am using the GetAttr constant, with the reference being "P:\", and it returns 48, when I would expect 16, because it is a directory. What does the 48 reference to?
    I know what the constants 0,1,2,4,8,16,32 mean. Is there a full listing somewhere? I have also recieved the constant 22 for my "C:\"

    Many Thanks in advance

    Justin

  2. #2
    Bob Phillips
    Guest

    Re: Question about VB constants

    48 is 16 + 32, so it means it has the attributes of directory and archive.

    To check if your attribute is set, do something like

    GetAttr(filename) AND 16

    A non-zero result means it is set.

    HTH

    Bob

    "turnerje" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I am using the GetAttr constant, with the reference being "P:\", and it
    > returns 48, when I would expect 16, because it is a directory. What
    > does the 48 reference to?
    > I know what the constants 0,1,2,4,8,16,32 mean. Is there a full listing
    > somewhere? I have also recieved the constant 22 for my "C:\"
    >
    > Many Thanks in advance
    >
    > Justin
    >
    >
    > --
    > turnerje
    > ------------------------------------------------------------------------
    > turnerje's Profile:
    > http://www.excelforum.com/member.php...o&userid=25694
    > View this thread: http://www.excelforum.com/showthread...hreadid=473066
    >




  3. #3
    Myrna Larson
    Guest

    Re: Question about VB constants

    48 = 32 + 16 'directory + changed
    22 = 16 + 4 + 2 'directory + system + hidden

    The list of attributes that you see in Help IS the "full listing".

    A file or directory can have move than one of the attributes: e.g. it can be
    read-only, hidden, system, and directory with the archive bit set. All of that
    information is returned on one value, which is a "bit map".

    To determine whether your filespec is a directory, your would use something
    like this

    If (GetAttr(FileSpec) And vbDirectory) Then

    which is directly analogous to the example in Help.

    From HELP(I have added caps for emphasis):

    "The value returned by GetAttr is the *SUM* of the following attribute values:

    Constant Value Description
    vbNormal 0 Normal.
    vbReadOnly 1 Read-only.
    vbHidden 2 Hidden.
    vbSystem 4 System file.
    vbDirectory 16 Directory or folder.
    vbArchive 32 File has changed since last backup.
    vbAlias 64 Specified file name is an alias. Available only on Mac

    .....
    To *DETERMINE WHICH ATTRIBUTES ARE SET, USE THE AND OPERATOR* to perform a
    bitwise comparison of the value returned by the GetAttr function and the value
    of the individual file attribute you want. If the result is not zero, that
    attribute is set for the named file."

    On Tue, 4 Oct 2005 12:37:29 -0500, turnerje
    <[email protected]> wrote:

    >
    >I am using the GetAttr constant, with the reference being "P:\", and it
    >returns 48, when I would expect 16, because it is a directory. What
    >does the 48 reference to?
    >I know what the constants 0,1,2,4,8,16,32 mean. Is there a full listing
    >somewhere? I have also recieved the constant 22 for my "C:\"
    >
    >Many Thanks in advance
    >
    >Justin


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1