# Visual Basic > Visual Basic 6 and Earlier >  Run-time error '76':

## Gymbo

Path not found

Runs fine from the IDE but produces the error when compiled.



```
Dim ps%, msg$, path$, cow$

msg = "Please pick a puzzle size BETWEEN 4 and 21."
Redo:

cow = InputBox(msg)

If cow = "" Then
    End
    Else: ps = CInt(cow)
End If

If ps < 5 Or ps > 20 Then
    cow = MsgBox("Read the instructions!", vbExclamation, "Wrong!")
    msg = msg & Chr(13) & Chr(13) & "Is " & ps & " between 5 and 20?"
    GoTo Redo
End If

Dim i%, j%(40), k%(40), n, h, m, ps2%, rtn As Long, rtn0%, sFileSpec$, spath$, Folder$

spath = Environ("homedrive") & Environ("homepath")  'C:\ &  \Users\user name

    Folder = spath & "\AppData\Roaming\Gymbo\Puzzles"    'C:\Users\Jim Allen\....\Puzzles
```

Runs through the message box the produces the error. Tried placing a stop statement before spath the error still showed up.




> Can you give a better explanation of what is happening.
> 
> What is the path of the file in the IDE?
> What is the path of the file from the EXE?
> Are both running on the same computer?
> Are both running with the same elevation?


IDE = D:\Documents\Visual Basic Projects\Star Puzzles
EXE = D:\Documents\Visual Basic Projects\Star Puzzles
yes
yes

----------


## DataMiser

Do you have a timer running somewhere? They behave differently when compiled

----------


## OptionBase1

The code you posted can't be generating the error message, since there is no attempted file access in the code you posted.  Presumably at some point in your code you are attempting to read and/or write to a file or files using the spath/Folder variables, so the code that does that would be relevant to the error message you are receiving.

----------


## dilettante

```
    Const ssfAPPDATA = &H1A
    With CreateObject("Shell.Application")
        MsgBox .NameSpace(ssfAPPDATA).Self.Path
    End With
```

----------


## Gymbo

@DataMiser, no timer

@dilettante, that code is way over my head, how would it be used?

A trimmed down version of the code:



```
Public Sub Main()
Dim ps%, msg$, path$, cow$

msg = "Please pick a puzzle size BETWEEN 4 and 21."
Redo:

cow = InputBox(msg)

If cow = "" Then
    End
    Else: ps = CInt(cow)
End If

If ps < 5 Or ps > 20 Then
    cow = MsgBox("Read the instructions!", vbExclamation, "Wrong!")
    msg = msg & Chr(13) & Chr(13) & "Is " & ps & " between 5 and 20?"
    GoTo Redo
End If

Dim i%, j%(40), k%(40), n, h, m, ps2%, rtn As Long, rtn0%, sFileSpec$, spath$, Folder$

spath = Environ("homedrive") & Environ("homepath")  'C:\ &  \Users\user name

    Folder = spath & "\AppData\Roaming\Gymbo\Puzzles"    'C:\Users\Jim Allen\....\Puzzles
    
sFileSpec = Folder & "\Drawings\Star" & ps & "puzzle.dcd"

ps2 = ps * 2
For i = 1 To ps2
    j(i) = i
Next

Randomize

Select Case ps
    Case 5
        n = 0
a1:
        m = m + 1
        h = (9 * Rnd)
        If j(h) = 10 Then GoTo a1
        k(n) = j(h)
        n = n + 1
        If n = 10 Then GoTo a2
        
        j(h) = 10
        GoTo a1
End Select

n = 1
a3:
m = m + 1
h = ((ps2 - 1) * Rnd) + 1    '13
If j(h) = ps2 + 1 Then GoTo a3   '15

k(n) = j(h)
n = n + 1
If n = ps2 + 1 Then GoTo a2

j(h) = ps2 + 1
GoTo a3

a2:

cow = Folder & "\star" & ps & ".txt"

Open cow For Input As #1
    Input #1, rtn0  'solved puzzles number
Close #1
    
rtn0 = rtn0 + 1

Open Folder & "\star" & ps & ".txt" For Output As #1

    Print #1, rtn0
    
    If ps = 5 Then  'ps2 = 9
    
        For i = 0 To 9
            Print #1, k(i)
        Next
    Else
        For i = 1 To ps2
            Print #1, k(i)
        Next
    End If
    
Select Case ps
    Case 5
        GoSub prt5
|
|
End Select

Close #1

rtn = ShellExecute(0, "Open", sFileSpec, vbNullString, vbNullString, SW_SHOWNORMAL) 'DC file

Open Folder & "\Which.txt" For Output As #1

    Print #1, ps

Close #1

End

prt5:
    Print #1, k(4) + k(5) + k(9)
    Print #1, k(0) + k(5) + k(6)
    Print #1, k(1) + k(6) + k(7)
    Print #1, k(2) + k(7) + k(8)
    Print #1, k(3) + k(8) + k(9)
    Print #1, k(5) + k(6) + k(7) + k(8) + k(9)
Return
|
|
|
|
End Sub
```

----------


## Gymbo

I will not mark this as resolved - but this morning I added a Stop Statement after the MsgBox routine, then after the Dim Statement, after the spath line and after the Folder line, one at a time in that order and the compiled program worked like running it from the IDE once I commented out that last Stop Statement.

I did not reinstall the project on my computer (I did put the computer to sleep). I'm happy it works but can't explain why I got the error yesterday.

----------

