home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / FERRAMEN / SPELMATE / SPEL.ZIP / GETFILE.FR$ / getfile.frm (.txt)
Encoding:
Visual Basic Form  |  1993-07-09  |  5.4 KB  |  206 lines

  1. VERSION 2.00
  2. Begin Form GetFile 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Select a File"
  5.    Height          =   3885
  6.    Icon            =   0
  7.    Left            =   1005
  8.    LinkMode        =   1  'Source
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   3510
  11.    ScaleWidth      =   6285
  12.    Top             =   1200
  13.    Width           =   6375
  14.    Begin DriveListBox Drive1 
  15.       Height          =   315
  16.       Left            =   4785
  17.       TabIndex        =   3
  18.       Top             =   1800
  19.       Width           =   1215
  20.    End
  21.    Begin DirListBox Dir1 
  22.       Height          =   1815
  23.       Left            =   2280
  24.       TabIndex        =   2
  25.       Top             =   1455
  26.       Width           =   2265
  27.    End
  28.    Begin FileListBox File1 
  29.       Height          =   2175
  30.       Left            =   240
  31.       TabIndex        =   1
  32.       Top             =   1080
  33.       Width           =   1800
  34.    End
  35.    Begin CommandButton Command2 
  36.       Caption         =   "Cancel"
  37.       Height          =   375
  38.       Left            =   4935
  39.       TabIndex        =   5
  40.       Top             =   720
  41.       Width           =   1095
  42.    End
  43.    Begin CommandButton Command1 
  44.       Caption         =   "OK"
  45.       Default         =   -1  'True
  46.       Height          =   375
  47.       Left            =   4935
  48.       TabIndex        =   4
  49.       Top             =   240
  50.       Width           =   1095
  51.    End
  52.    Begin TextBox Text1 
  53.       Height          =   315
  54.       Left            =   1200
  55.       TabIndex        =   0
  56.       Text            =   "Text1"
  57.       Top             =   240
  58.       Width           =   3495
  59.    End
  60.    Begin Label Label5 
  61.       AutoSize        =   -1  'True
  62.       Caption         =   "Drives:"
  63.       Height          =   195
  64.       Left            =   4785
  65.       TabIndex        =   8
  66.       Top             =   1575
  67.       Width           =   615
  68.    End
  69.    Begin Label Label4 
  70.       AutoSize        =   -1  'True
  71.       Caption         =   "Directories:"
  72.       Height          =   195
  73.       Left            =   2280
  74.       TabIndex        =   7
  75.       Top             =   1200
  76.       Width           =   990
  77.    End
  78.    Begin Label Label3 
  79.       AutoSize        =   -1  'True
  80.       Caption         =   "Files:"
  81.       Height          =   195
  82.       Left            =   240
  83.       TabIndex        =   10
  84.       Top             =   840
  85.       Width           =   465
  86.    End
  87.    Begin Label Label1 
  88.       AutoSize        =   -1  'True
  89.       Height          =   195
  90.       Left            =   2160
  91.       TabIndex        =   6
  92.       Top             =   750
  93.       Width           =   2055
  94.    End
  95.    Begin Label Label2 
  96.       AutoSize        =   -1  'True
  97.       Caption         =   "File Name:"
  98.       Height          =   195
  99.       Left            =   240
  100.       TabIndex        =   9
  101.       Top             =   240
  102.       Width           =   915
  103.    End
  104. 'Declarations for GETFILE.FRM
  105. Const TEXTFLAG = 0
  106. Const FILEFLAG = 1
  107. Const DIRFLAG = 2
  108. Dim SelectFlag As Integer
  109. Sub Command1_Click ()
  110.    On Error GoTo ErrorTrap
  111.    If SelectFlag = TEXTFLAG Then
  112.       File1.FileName = Text1.Text
  113.       If FileSelected = True Then
  114.          On Error GoTo 0
  115.          Unload GetFile
  116.          Exit Sub
  117.       End If
  118.       Dir1.Path = File1.Path
  119.    ElseIf SelectFlag = DIRFLAG Then
  120.       Dir1.Path = Dir1.List(Dir1.ListIndex)
  121.       Dir1_Change
  122.    Else
  123.       If Right$(Dir1.Path, 1) = "\" Then
  124.          FullFilePath = Dir1.Path + Text1.Text
  125.       Else
  126.          FullFilePath = Dir1.Path + "\" + Text1.Text
  127.       End If
  128.       FileSelected = True
  129.       Unload GetFile
  130.    End If
  131.    Exit Sub
  132. ErrorTrap:
  133.    Beep
  134.    Resume Next
  135. End Sub
  136. Sub Command2_Click ()
  137.    Unload GetFile
  138. End Sub
  139. Sub Dir1_Change ()
  140.    FillLabel1
  141.    File1.FileName = Dir1.Path + "\" + File1.Pattern
  142.    Drive1.Drive = Dir1.Path
  143.    Text1.Text = File1.Pattern
  144.    SelectFlag = DIRFLAG
  145. End Sub
  146. Sub Dir1_Click ()
  147.    SelectFlag = DIRFLAG
  148. End Sub
  149. Sub Drive1_Change ()
  150.    Dir1.Path = Drive1.Drive
  151.    Text1.Text = File1.Pattern
  152.    SelectFlag = DIRFLAG
  153. End Sub
  154. Sub File1_Click ()
  155.    Text1.Text = File1.FileName
  156.    SelectFlag = FILEFLAG
  157. End Sub
  158. Sub File1_DblClick ()
  159.    If SelectFlag = TEXTFLAG Then
  160.       FullFilePath = File1.Path + "\" + File1.FileName
  161.    Else
  162.       If Right$(Dir1.Path, 1) = "\" Then
  163.          FullFilePath = Dir1.Path + Text1.Text
  164.       Else
  165.          FullFilePath = Dir1.Path + "\" + Text1.Text
  166.       End If
  167.    End If
  168.    FileSelected = True
  169.    Unload GetFile
  170. End Sub
  171. Sub FillLabel1 ()
  172.    Label1.Caption = Dir1.Path
  173.    If Label1.Width > 2055 Then
  174.       a$ = Left$(Dir1.Path, 3)
  175.       b$ = Mid$(Dir1.Path, 4)
  176.       Do While InStr(b$, "\")
  177.          b$ = Mid$(b$, InStr(b$, "\") + 1)
  178.       Loop
  179.       Label1.Caption = a$ + "...\" + b$
  180.    End If
  181. End Sub
  182. Sub Form_Load ()
  183.    GetFile.Left = (Screen.Width - GetFile.Width) / 2
  184.    GetFile.Top = (Screen.Height - GetFile.Height) / 2
  185.    If FullFilePath <> "" Then
  186.       Tmp$ = FullFilePath
  187.       Do Until Right$(Tmp$, 1) = "\"
  188.          Tmp$ = Left$(Tmp$, Len(Tmp$) - 1)
  189.       Loop
  190.       Tmp$ = Tmp$ + WILDCARD$
  191.       File1.FileName = Tmp$
  192.       Dir1.Path = File1.Path
  193.    End If
  194.    File1.Pattern = WILDCARD$
  195.    FillLabel1
  196.    Text1.Text = File1.Pattern
  197.    SelectFlag = DIRFLAG
  198.    FileSelected = False
  199. End Sub
  200. Sub Form_Resize ()
  201.    Text1.SetFocus
  202. End Sub
  203. Sub Text1_Change ()
  204.    SelectFlag = TEXTFLAG
  205. End Sub
  206.