Why does CurDir() change persist?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lance

    #1

    Why does CurDir() change persist?

    Hi All,

    I change the current directory in a proc, using CurDir(). The change
    persists across executions. I would like the CurDir() return value to be the
    same at the start of each execution. Any suggestions will be appreciated.
    The code below illustrates the problem. Thanks.

    Dim currentDir As String
    MsgBox CurDir()

    currentDir = CurDir() + "\foo"

    MsgBox currentDir

    ChDir (currentDir )




  • Randy Birch

    #2
    Re: Why does CurDir() change persist?

    CurDir does not change the working folder, only ChDrive/ChDir does. Not
    sure what your example is supposed to prove, other than the second
    messagebox has the same value as the first one but with \foo appended.

    --

    Randy Birch
    MS MVP Visual Basic

    ----------------------------------------------------------------------------
    Read. Decide. Sign the petition to Microsoft.

    ----------------------------------------------------------------------------



    "Lance" <Lbrannma@yahoo .com> wrote in message
    news:CwcLe.3140 9$d5.184612@new sb.telia.net...
    : Hi All,
    :
    : I change the current directory in a proc, using CurDir(). The change
    : persists across executions. I would like the CurDir() return value to be
    the
    : same at the start of each execution. Any suggestions will be appreciated.
    : The code below illustrates the problem. Thanks.
    :
    : Dim currentDir As String
    : MsgBox CurDir()
    :
    : currentDir = CurDir() + "\foo"
    :
    : MsgBox currentDir
    :
    : ChDir (currentDir )
    :
    :
    :
    :

    Comment

    Working...