home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / vsflex / demo / fword.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-30  |  4.2 KB  |  137 lines

  1. VERSION 2.00
  2. Begin Form fWord 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Word Count"
  6.    ClientHeight    =   4215
  7.    ClientLeft      =   1410
  8.    ClientTop       =   2400
  9.    ClientWidth     =   5880
  10.    Height          =   4620
  11.    Left            =   1350
  12.    LinkTopic       =   "Form2"
  13.    ScaleHeight     =   4215
  14.    ScaleWidth      =   5880
  15.    Top             =   2055
  16.    Width           =   6000
  17.    Begin CommandButton Command1 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "Number Count"
  20.       FontBold        =   0   'False
  21.       FontItalic      =   0   'False
  22.       FontName        =   "MS Sans Serif"
  23.       FontSize        =   8.25
  24.       FontStrikethru  =   0   'False
  25.       FontUnderline   =   0   'False
  26.       Height          =   420
  27.       Index           =   2
  28.       Left            =   4410
  29.       TabIndex        =   4
  30.       Top             =   1260
  31.       Width           =   1290
  32.    End
  33.    Begin vsFlexString fs 
  34.       Left            =   4230
  35.       Pattern         =   "[^ ,    ]*"
  36.       Text            =   "VideoSoft FlexString"
  37.       Top             =   3135
  38.    End
  39.    Begin CommonDialog CMDialog1 
  40.       Left            =   3675
  41.       Top             =   3165
  42.    End
  43.    Begin CommandButton Command1 
  44.       BackColor       =   &H00C0C0C0&
  45.       Caption         =   "Letter Count"
  46.       FontBold        =   0   'False
  47.       FontItalic      =   0   'False
  48.       FontName        =   "MS Sans Serif"
  49.       FontSize        =   8.25
  50.       FontStrikethru  =   0   'False
  51.       FontUnderline   =   0   'False
  52.       Height          =   420
  53.       Index           =   1
  54.       Left            =   4410
  55.       TabIndex        =   3
  56.       Top             =   765
  57.       Width           =   1290
  58.    End
  59.    Begin CommandButton Command1 
  60.       BackColor       =   &H00C0C0C0&
  61.       Caption         =   "&Get File"
  62.       FontBold        =   0   'False
  63.       FontItalic      =   0   'False
  64.       FontName        =   "MS Sans Serif"
  65.       FontSize        =   8.25
  66.       FontStrikethru  =   0   'False
  67.       FontUnderline   =   0   'False
  68.       Height          =   420
  69.       Index           =   9
  70.       Left            =   4425
  71.       TabIndex        =   0
  72.       Top             =   3600
  73.       Width           =   1290
  74.    End
  75.    Begin CommandButton Command1 
  76.       BackColor       =   &H00C0C0C0&
  77.       Caption         =   "Word Count"
  78.       FontBold        =   0   'False
  79.       FontItalic      =   0   'False
  80.       FontName        =   "MS Sans Serif"
  81.       FontSize        =   8.25
  82.       FontStrikethru  =   0   'False
  83.       FontUnderline   =   0   'False
  84.       Height          =   420
  85.       Index           =   0
  86.       Left            =   4410
  87.       TabIndex        =   2
  88.       Top             =   270
  89.       Width           =   1290
  90.    End
  91.    Begin TextBox Text1 
  92.       BackColor       =   &H00FFFFFF&
  93.       FontBold        =   0   'False
  94.       FontItalic      =   0   'False
  95.       FontName        =   "MS Sans Serif"
  96.       FontSize        =   9.75
  97.       FontStrikethru  =   0   'False
  98.       FontUnderline   =   0   'False
  99.       ForeColor       =   &H00000000&
  100.       Height          =   3945
  101.       Left            =   255
  102.       MultiLine       =   -1  'True
  103.       TabIndex        =   1
  104.       Text            =   "This is a sample piece of text. Count words, count letters, count numbers."
  105.       Top             =   240
  106.       Width           =   3945
  107.    End
  108. Option Explicit
  109. Sub Command1_Click (Index%)
  110.   fs.Text = Text1
  111.   Select Case Index
  112.     Case 9
  113.       DoGetFile
  114.       Exit Sub
  115.     Case 0: fs.Pattern = "[^ .\t]+"
  116.     Case 1: fs.Pattern = "[a-zA-Z]"
  117.     Case 2: fs.Pattern = "[0-9]+"
  118.   End Select
  119.   Caption = "Word Count - " & fs.MatchCount & " match(es)"
  120. End Sub
  121. Sub DoGetFile ()
  122.   On Error Resume Next
  123.   Text1 = ""
  124.   ' Load Dialog
  125.   cmdialog1.Action = 1
  126.   ' Validate Filename and size
  127.   If cmdialog1.Filename = "" Then Exit Sub
  128.   If FileLen(cmdialog1.Filename) > 64000 Then
  129.       MsgBox "File is too large"
  130.       Text1 = "File is too large to be loaded"
  131.       Exit Sub
  132.   End If
  133.   Open cmdialog1.Filename For Input As #1
  134.   Text1 = Input(LOF(1), 1)
  135.   Close #1
  136. End Sub
  137.