home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form WordCnt
- BackColor = &H00C0C0C0&
- BorderStyle = 3 'Fixed Double
- Caption = "Word Count"
- ClientHeight = 4455
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- ControlBox = 0 'False
- Height = 4860
- Left = 1035
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4455
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin CommandButton Command2
- BackColor = &H00C0C0C0&
- Cancel = -1 'True
- Caption = "O &K A Y"
- Height = 375
- Left = 3720
- TabIndex = 2
- TabStop = 0 'False
- Top = 3840
- Width = 3255
- End
- Begin CommandButton CmdCountWords
- BackColor = &H00C0C0C0&
- Caption = "&Count Words"
- Height = 375
- Left = 480
- TabIndex = 1
- TabStop = 0 'False
- Top = 3840
- Width = 3255
- End
- Begin TextBox Text1
- BackColor = &H00FFFF00&
- Height = 3015
- Left = 480
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 0
- Top = 600
- Width = 6495
- End
- Begin Label Label1
- Alignment = 2 'Center
- BackStyle = 0 'Transparent
- Caption = "Type some text and then press Count Words (works with selected text too):"
- ForeColor = &H00000080&
- Height = 255
- Left = 480
- TabIndex = 3
- Top = 240
- Width = 6495
- End
- Sub CmdCountWords_Click ()
- 'count speed (slow end) is 1800 words/sec on a 386-DX/33
- Screen.MousePointer = 11
- TotalWords% = 0
- nl$ = Chr$(13) + Chr$(10)
- If Text1.SelText = "" Then
- Word$ = Text1.Text 'if NO text highlighted
- CountType$ = "TOTAL"
- Else
- Word$ = Text1.SelText 'if text highlighted
- CountType$ = "SELECTED"
- End If
- If Len(Word$) = 0 Then
- TotalWords% = 0
- GoTo WCdone
- End If
- If InStr(Word$, nl$) = 0 Then
- TotalWords% = CountWords(Word$)
- GoTo WCdone
- End If
- Word$ = Trim$(Word$) + nl$
- Do While Len(Word$) > 0
- OldPos% = InStr(Word$, nl$)
- If OldPos% = 0 Then Exit Do
- TempWord$ = Mid$(Word$, 1, OldPos% - 1)
- x% = CountWords(TempWord$)
- TotalWords% = TotalWords% + x%
- Word$ = Mid$(Word$, OldPos% + 2, Len(Word$) - OldPos% + 2)
- Loop
- WCdone:
- Screen.MousePointer = 0
- msg$ = "The " + CountType$ + " word count is: " + Format$(TotalWords%, "###,##0")
- MsgBox msg$, 64, "Word Count Test"
- Text1.SetFocus
- End Sub
- Sub Command2_Click ()
- Unload Me
- End Sub
- Sub Form_Load ()
- 'use this as a speed/accuracy test for long strings
- 'test$ = ""
- 'nl$ = Chr$(13) + Chr$(10)
- 'k$ = "Now is the time for all good men to come to the aid of their country." + nl$
- 'For x = 1 To 450: test$ = test$ + k$: Next
- 'Text1.Text = test$
- FormCenterScreen Me
- Screen.MousePointer = 0
- End Sub
- Sub Form_Paint ()
- DoForm3D Me, sunken, 3, 0
- DoForm3D Me, raised, 1, 3
- DoControl3D Text1, raised, 2
- End Sub
-