home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / LineIndex_512871262002.psc / LineIndex / 01 / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-01-27  |  3.3 KB  |  109 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "LineIndex Demo"
  5.    ClientHeight    =   6090
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   6945
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6090
  11.    ScaleWidth      =   6945
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton Command1 
  14.       Caption         =   "Select 100 Lines"
  15.       Height          =   495
  16.       Left            =   2760
  17.       TabIndex        =   2
  18.       Top             =   720
  19.       Width           =   1815
  20.    End
  21.    Begin VB.TextBox Text1 
  22.       Height          =   4695
  23.       Left            =   120
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   1
  27.       Top             =   1320
  28.       Width           =   6735
  29.    End
  30.    Begin VB.CommandButton Command2 
  31.       Caption         =   "RANDOM Read 10000 Lines by Number"
  32.       Height          =   495
  33.       Left            =   2760
  34.       TabIndex        =   0
  35.       Top             =   120
  36.       Width           =   1815
  37.    End
  38. Attribute VB_Name = "frmMain"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = False
  41. Attribute VB_PredeclaredId = True
  42. Attribute VB_Exposed = False
  43. Option Explicit
  44. Private myFile          As New cFileLines
  45. Private lngLinesRead    As Long
  46. Private Sub Command1_Click()
  47.   Dim lngLocation As Long
  48.   On Error Resume Next
  49.   lngLocation = InputBox("Enter a position")
  50.   Text1.Text = myFile.Lines2String(lngLocation, 100)
  51. End Sub
  52. Private Sub Command2_Click()
  53.   Dim sinS             As Single
  54.   Dim sinE             As Single
  55.   Dim lngCount         As Long
  56.   Dim strDummy         As String
  57.   Dim lngMax           As Long
  58.   Dim lngRND           As Long
  59.   Me.Cls
  60.   lngMax = 10000
  61.   Randomize Timer
  62.   sinS = Timer
  63.   With myFile
  64.     For lngCount = 1 To lngMax
  65.       lngRND = CLng(Rnd(1) * lngLinesRead) + 1
  66.       strDummy = .Lines2String(lngRND)
  67.     Next
  68.   End With
  69.   sinE = Timer
  70.   Me.Print "#Lines read RANDOMLY:" & lngMax & _
  71.     vbNewLine & "Time: " & sinE - sinS & " s."
  72. End Sub
  73. Private Sub MakeTestFile()
  74.   Dim lngCount        As Long
  75.   Dim strTest As String
  76.   On Error Resume Next
  77.   '***  omitted for debugging:
  78.   'Randomize Timer
  79.   Kill App.Path & "\data1.dat"
  80.   strTest = "Just some text to test a little...Just some text to test a little...Just some text to test a little..."
  81.   Open App.Path & "\data1.dat" For Output As #1
  82.   For lngCount = 1 To 100000
  83.     Print #1, "This is line# " & Format(lngCount, "00000") & " >>" & Left$(strTest, CLng(Rnd(1) * 70) + 1) & "<<"
  84.   Next
  85.   Close
  86. End Sub
  87. Private Sub Form_Activate()
  88.   Dim sinS             As Single
  89.   Dim sinE             As Single
  90.   With myFile
  91.     Me.Print "Scanning file...": DoEvents
  92.     sinS = Timer
  93.     lngLinesRead = .ReadFile(App.Path & "\data1.dat")
  94.     sinE = Timer
  95.     Me.Print "File Size: " & myFile.LengthOfFile & " bytes"
  96.     Me.Print lngLinesRead & " lines in file.": DoEvents
  97.     Me.Print "Memory consumption: " & lngLinesRead * 4 + 2000 & " bytes": DoEvents
  98.     Me.Print "Time: " & sinE - sinS & " s.": DoEvents
  99.   End With
  100. End Sub
  101. Private Sub Form_Load()
  102.   MakeTestFile
  103. End Sub
  104. Private Sub Form_Terminate()
  105.   On Error Resume Next
  106.   Set myFile = Nothing
  107.   Kill App.Path & "\data1.dat"
  108. End Sub
  109.