home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_2 / STR_PLUS / WORDCNT.FRM (.txt) < prev   
Encoding:
Visual Basic Form  |  1994-07-19  |  3.6 KB  |  115 lines

  1. VERSION 2.00
  2. Begin Form WordCnt 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Word Count"
  6.    ClientHeight    =   4455
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   7365
  10.    ControlBox      =   0   'False
  11.    Height          =   4860
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   4455
  17.    ScaleWidth      =   7365
  18.    Top             =   1140
  19.    Width           =   7485
  20.    Begin CommandButton Command2 
  21.       BackColor       =   &H00C0C0C0&
  22.       Cancel          =   -1  'True
  23.       Caption         =   "O &K A Y"
  24.       Height          =   375
  25.       Left            =   3720
  26.       TabIndex        =   2
  27.       TabStop         =   0   'False
  28.       Top             =   3840
  29.       Width           =   3255
  30.    End
  31.    Begin CommandButton CmdCountWords 
  32.       BackColor       =   &H00C0C0C0&
  33.       Caption         =   "&Count Words"
  34.       Height          =   375
  35.       Left            =   480
  36.       TabIndex        =   1
  37.       TabStop         =   0   'False
  38.       Top             =   3840
  39.       Width           =   3255
  40.    End
  41.    Begin TextBox Text1 
  42.       BackColor       =   &H00FFFF00&
  43.       Height          =   3015
  44.       Left            =   480
  45.       MultiLine       =   -1  'True
  46.       ScrollBars      =   2  'Vertical
  47.       TabIndex        =   0
  48.       Top             =   600
  49.       Width           =   6495
  50.    End
  51.    Begin Label Label1 
  52.       Alignment       =   2  'Center
  53.       BackStyle       =   0  'Transparent
  54.       Caption         =   "Type some text and then press Count Words (works with selected text too):"
  55.       ForeColor       =   &H00000080&
  56.       Height          =   255
  57.       Left            =   480
  58.       TabIndex        =   3
  59.       Top             =   240
  60.       Width           =   6495
  61.    End
  62. Sub CmdCountWords_Click ()
  63.     'count speed (slow end) is 1800 words/sec on a 386-DX/33
  64.     Screen.MousePointer = 11
  65.     TotalWords% = 0
  66.     nl$ = Chr$(13) + Chr$(10)
  67.     If Text1.SelText = "" Then
  68.         Word$ = Text1.Text      'if NO text highlighted
  69.         CountType$ = "TOTAL"
  70.         Else
  71.         Word$ = Text1.SelText   'if text highlighted
  72.         CountType$ = "SELECTED"
  73.         End If
  74.     If Len(Word$) = 0 Then
  75.         TotalWords% = 0
  76.         GoTo WCdone
  77.         End If
  78.     If InStr(Word$, nl$) = 0 Then
  79.         TotalWords% = CountWords(Word$)
  80.         GoTo WCdone
  81.         End If
  82.    Word$ = Trim$(Word$) + nl$
  83.    Do While Len(Word$) > 0
  84.         OldPos% = InStr(Word$, nl$)
  85.         If OldPos% = 0 Then Exit Do
  86.         TempWord$ = Mid$(Word$, 1, OldPos% - 1)
  87.         x% = CountWords(TempWord$)
  88.         TotalWords% = TotalWords% + x%
  89.         Word$ = Mid$(Word$, OldPos% + 2, Len(Word$) - OldPos% + 2)
  90.         Loop
  91. WCdone:
  92.     Screen.MousePointer = 0
  93.     msg$ = "The " + CountType$ + " word count is:  " + Format$(TotalWords%, "###,##0")
  94.     MsgBox msg$, 64, "Word Count Test"
  95.     Text1.SetFocus
  96. End Sub
  97. Sub Command2_Click ()
  98.     Unload Me
  99. End Sub
  100. Sub Form_Load ()
  101.     'use this as a speed/accuracy test for long strings
  102.     'test$ = ""
  103.     'nl$ = Chr$(13) + Chr$(10)
  104.     'k$ = "Now is the time for all good men to come to the aid of their country." + nl$
  105.     'For x = 1 To 450: test$ = test$ + k$: Next
  106.     'Text1.Text = test$
  107.     FormCenterScreen Me
  108.     Screen.MousePointer = 0
  109. End Sub
  110. Sub Form_Paint ()
  111.     DoForm3D Me, sunken, 3, 0
  112.     DoForm3D Me, raised, 1, 3
  113.     DoControl3D Text1, raised, 2
  114. End Sub
  115.