home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / parsed / selfile.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-02  |  3.7 KB  |  130 lines

  1. VERSION 2.00
  2. Begin Form frmSelFile 
  3.    Caption         =   "Select Text File To Load"
  4.    ClientHeight    =   4635
  5.    ClientLeft      =   1515
  6.    ClientTop       =   840
  7.    ClientWidth     =   6285
  8.    Height          =   5040
  9.    Left            =   1455
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4635
  12.    ScaleWidth      =   6285
  13.    Top             =   495
  14.    Width           =   6405
  15.    Begin CommandButton cmdLoad 
  16.       Caption         =   "&Load File"
  17.       Height          =   375
  18.       Left            =   1815
  19.       TabIndex        =   2
  20.       Top             =   3840
  21.       Width           =   2340
  22.    End
  23.    Begin TextBox txtPattern 
  24.       Height          =   315
  25.       Left            =   435
  26.       TabIndex        =   6
  27.       Top             =   450
  28.       Width           =   2355
  29.    End
  30.    Begin TextBox txtFile 
  31.       Height          =   315
  32.       Left            =   420
  33.       TabIndex        =   7
  34.       Top             =   3420
  35.       Width           =   5115
  36.    End
  37.    Begin DriveListBox Drive1 
  38.       Height          =   315
  39.       Left            =   2940
  40.       TabIndex        =   5
  41.       Top             =   510
  42.       Width           =   2535
  43.    End
  44.    Begin DirListBox Dir1 
  45.       Height          =   1830
  46.       Left            =   2940
  47.       TabIndex        =   1
  48.       Top             =   1050
  49.       Width           =   2535
  50.    End
  51.    Begin FileListBox File1 
  52.       Height          =   2175
  53.       Left            =   450
  54.       TabIndex        =   0
  55.       Top             =   870
  56.       Width           =   1905
  57.    End
  58.    Begin Label Label2 
  59.       Caption         =   "Current File:"
  60.       Height          =   255
  61.       Left            =   450
  62.       TabIndex        =   4
  63.       Top             =   3120
  64.       Width           =   1755
  65.    End
  66.    Begin Label Label1 
  67.       Caption         =   "File Patterns:"
  68.       Height          =   255
  69.       Left            =   480
  70.       TabIndex        =   3
  71.       Top             =   90
  72.       Width           =   1290
  73.    End
  74. Sub cmdLoad_Click ()
  75.    Dim FileNam$, FileContents$, msg$
  76.    Dim FileLength&
  77.    Screen.MousePointer = HOURGLASS
  78.    'get file name and length of selected file
  79.    FileNam$ = Trim$(txtFile)
  80.    FileLength& = FileLen(FileNam$)
  81.    'bail if file too big
  82.    If FileLength& > 28000 Then
  83.       msg$ = "The file you selected is too large. Please try another file."
  84.       MsgBox msg$, MB_ICONINFORMATION
  85.       Screen.MousePointer = DEFAULT
  86.       File1.SetFocus
  87.    Else
  88.       'load file and put contents into txtFileContents on frmParse
  89.       FileContents$ = LoadFile$(Trim$(txtFile), FileLength&)
  90.       frmParse!txtFileContents = FileContents$
  91.       'display filename on frmParse
  92.       frmParse!lblFileName = FileNam$
  93.       'display file length info on frmParse
  94.       frmParse!lblFileLen = "Length of File: " & Format$(FileLength&, "##,###") & " bytes."
  95.       Unload Me
  96.    End If
  97. End Sub
  98. Sub Dir1_Change ()
  99.     File1.Path = Dir1.Path
  100. End Sub
  101. Sub Dir1_Click ()
  102.     txtFile.Text = ""
  103. End Sub
  104. Sub Drive1_Change ()
  105.     Dir1.Path = Drive1.Drive
  106. End Sub
  107. Sub File1_Click ()
  108.     Dim i%
  109.     For i% = 0 To File1.ListCount - 1
  110.         If File1.Selected(i%) = True Then
  111.             If Right$(Dir1.Path, 1) = "\" Then
  112.                 txtFile = File1.Path & File1.List(i%)
  113.             Else
  114.                 txtFile = File1.Path & "\" & File1.List(i%)
  115.             End If
  116.             Exit For
  117.         End If
  118.     Next i%
  119.     If txtFile <> "" Then cmdLoad.SetFocus
  120. End Sub
  121. Sub Form_Activate ()
  122.    Screen.MousePointer = DEFAULT
  123. End Sub
  124. Sub Form_Load ()
  125.     Drive1.Drive = "D:\"
  126.     File1.Path = Dir1.Path
  127.     File1.Pattern = "*.txt"
  128.     txtPattern = File1.Pattern
  129. End Sub
  130.