Results 1 to 13 of 13

Thread: Win 2000 Vs 95,98 Function question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    PA
    Posts
    5

    Question Win 2000 Vs 95,98 Function question

    the following line of code seems to be giving me errors on NT and 2000 computers. Any ideas if this function is supported on those operating systems?

    If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then docodehere

  2. #2
    What are the errors?

  3. #3
    Addicted Member
    Join Date
    Jun 2001
    Posts
    183
    Try this:

    If (GetAttr(DirPath & FileString) And vbDirectory) Then docodehere

    You need to do it this way, the And does a bitwise compare. If it's a directory, the If will test positive. This is for all Windows OS's

  4. #4
    Tygur
    Guest
    Originally posted by RyeBread
    Try this:

    If (GetAttr(DirPath & FileString) And vbDirectory) Then docodehere

    You need to do it this way, the And does a bitwise compare. If it's a directory, the If will test positive. This is for all Windows OS's
    No, you don't. Do you know what the And means? It works just as well whether or not you have the " = vbDirectory".

    "(GetAttr(DirPath & FileString) And vbDirectory)" will only ever return zero or vbDirectory. Checking to see if it's the same as vbDirectory (what it was doing before your change) is basically the same as checking to see if it's nonzero (what it does after your change), because it's only nonzero if it's the same as vbDirectory.

    Makes sense?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    PA
    Posts
    5

    still confused

    when i run my program on an NT or 2000 box i get the following error.

    run-time error '5':
    invalid procedure call or argument.

    the code runs fine on all 95/98 boxes. i just have the problem on NT and 2000.

    the line of code follows.

    If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then

    the above line is where the compiler stops. any help would be appreciated.!!!

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    You may want to check to see if there is a "\" at the end of your path before the filestring. This could cause the error if the directory doesn't exist.
    -Excalibur

  7. #7
    Tygur
    Guest
    Originally posted by ExcalibursZone
    You may want to check to see if there is a "\" at the end of your path before the filestring. This could cause the error if the directory doesn't exist.
    Yeah, it does give an error, but not that error.


    techster.
    What's in DirPath and FileString? If DirPath begins with "\\", that'll give you the error you're coming up with.

  8. #8
    Addicted Member
    Join Date
    Jun 2001
    Posts
    183
    Originally posted by Tygur

    No, you don't. Do you know what the And means? It works just as well whether or not you have the " = vbDirectory".

    "(GetAttr(DirPath & FileString) And vbDirectory)" will only ever return zero or vbDirectory. Checking to see if it's the same as vbDirectory (what it was doing before your change) is basically the same as checking to see if it's nonzero (what it does after your change), because it's only nonzero if it's the same as vbDirectory.

    Makes sense?
    Ah true. I read the statement too fast, thinking he had "(GetAttr(DirPath & FileString) = vbDirectory)", which is a problem.

    Yes I know what And does.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    PA
    Posts
    5

    Some more information

    here is the values of the variables

    dirpath = "C:\"
    filestring = "pagefile.sys"

    code in question:

    If (GetAttr(DirPath & FileString) And vbDirectory) = vbDirectory Then


    again only on NT and 2000 boxes do i get the error. Maybe a rights issue???? im stumped.

  10. #10
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    I get the same error. It may be due to NT security issues.
    -Excalibur

  11. #11
    Tygur
    Guest
    I'm running Win2K and windows is on drive D, so I tested it out with DirPath set to "d:\". I got error number 75, "Path/file access error". I'm logged in as an administrator, if it means anything.

    I guess you're just going to have to handle the error.

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    PA
    Posts
    5

    there must be a solution

    I can handle the error. the problem is that as my agency migrates to windows 2000. my applications will be useless.

    this is very frustrating. stupid microsoft!!!!! why cant they just have standards!!! well if anyone comes up with a solution please let me know.

    has anyone tried this with an api call instead? maybe windows 2000 will like that? who the heck knows.

    <sigh> thanks for your help all!

  13. #13
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    I tested this on several other files (I'm running Win2k) and it worked, just the pagefile.sys gave me issues. I even tested it with other files/directories and it worked. I'd say, just handle this one error the rest should be fine.
    -Excalibur

Posting Permissions

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



Click Here to Expand Forum to Full Width