This Button code will do the job. It just does not cancel gracefully(;-).
'Gcode Selection Box 
Sub GcodeSelect 
    Dim MyList() 
    Begin Dialog GcodeFileDlg 60, 60, 190, 220, "Gcode file selection", .DlgFunc 
        ListBox 10, 10, 150, 180, MyList(), .List1, 2 
        CancelButton 42, 198, 40, 12
        OKButton 90, 198, 40, 12    
       End Dialog
    
 Dim frame As GcodeFileDlg 
 
    ' Show the GcodeFile dialog 
    Dialog frame 
End Sub 
 
Function DlgFunc( controlID As String, action As Integer, suppValue As Integer) 
 
    DlgFunc = 1  ' Keep dialog active 
 
    Select Case action 
    Case 1 ' Initialize 
        temp = Dir( "c:\Mach3\Gcode\*.tap" ) 
        count = 0  
        While temp <> "" 
            count = count + 1 
            temp = Dir 
        Wend 
        Dim x() As String 
        ReDim x(count) 
        x(0) = Dir( "c:\Mach3\Gcode\*.tap" ) 
        For i = 1 To count 
            x(i) = Dir 
        Next i 
        DlgListBoxArray "List1", x() 
        
    Case 2 ' select
     
        Fname = (DlgText("List1"))
        LoadFIle("c:\Mach3\Gcode\" &DlgText("List1"))
        End
     End Select 
End Function
End