I've been trying to find out the error returned from MkDir to no avail. Err.Number is 0 and I can't find any other error mechanisms available.

On Error GoTo mkError
    MkDir txtDir(Index).Text
    On Error GoTo 0
    Exit Sub

mkError:
    On Error GoTo 0
    Text1.Text = Str(Err.LastDllError) + " "
    Text1.Text = Text1.Text + Str(Err.Number) + " "

I need to know if I get a 75 (path exists) or 76 (path not created) error. Where is this error returned?

Okay WaltP. The reason you are not retrieving any possible error that has been raised is because of your code and error handling. Please see comments I made to your code below...

'good, a well defined error handler label definition
On Error GoTo mkError

'side note: any text box can make a dir?
MkDir txtDir(Index).Text

'now here is where you tell the system that any error handler is disabled
On Error GoTo 0

'exit current sub so error handler is not executed if there is no error
Exit Sub
mkError:

'and here you say the same thing to the system, disable error handler
On Error GoTo 0

'which of course resets the error object and thus you don't return anything when you 
'do encounter an error (ALSO: Concatination of strings in VB6.0 uses the & character)
Text1.Text = Str(Err.LastDllError) + " "
Text1.Text = Text1.Text + Str(Err.Number) + " "

So what I would do, is to remove your line 7 on error goto 0 statement and you should be able to retrieve your error info. Also, you can reduce the amount of errors your recieve by checking to see if the directory exists with the Dir Function prior to trying to create it...

Also:

Exit Sub
mkError:

If Err.Number = 75 Or Err.Number = 76 Then
  'handle these here
Else
  MsgBox "FormModuleName.SubFunctionName " & Err.Number & ":" & Err.Description
End If

End Sub

Good Luck

Okay WaltP. The reason you are not retrieving any possible error that has been raised is because of your code and error handling. Please see comments I made to your code below...

mkError:

'and here you say the same thing to the system, disable error handler
On Error GoTo 0

'which of course resets the error object and thus you don't return anything when you 
'do encounter an error (ALSO: Concatination of strings in VB6.0 uses the & character)
Text1.Text = Str(Err.LastDllError) + " "
Text1.Text = Text1.Text + Str(Err.Number) + " "

DOH!!! That makes sense...

Thanks, VB

This article has been dead for over six months. Start a new discussion instead.