home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Programatically Working With Selected Text"
- ClientHeight = 4020
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- Height = 4425
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 4020
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin CommandButton Command3
- Caption = "Replace It!"
- Height = 500
- Left = 5400
- TabIndex = 5
- Top = 2040
- Width = 1455
- End
- Begin TextBox Text2
- Height = 380
- Left = 5400
- TabIndex = 3
- Top = 1200
- Width = 1455
- End
- Begin CommandButton Command2
- Caption = "End"
- Height = 500
- Left = 5400
- TabIndex = 2
- Top = 3000
- Width = 1455
- End
- Begin CommandButton Command1
- Caption = "Next Word"
- Height = 500
- Left = 5400
- TabIndex = 1
- Top = 240
- Width = 1455
- End
- Begin TextBox Text1
- Height = 3260
- HideSelection = 0 'False
- Left = 240
- MultiLine = -1 'True
- TabIndex = 0
- Top = 240
- Width = 4695
- End
- Begin Label Label1
- Caption = "Replacement"
- Height = 260
- Left = 5400
- TabIndex = 4
- Top = 960
- Width = 1335
- End
- Option Explicit
- Sub Command1_Click ()
- Static NotFirstTime As Integer
- Static PosSpace As Integer
- TryAgain:
- If NotFirstTime Then
- Text1.SelStart = PosSpace
- PosSpace = PosSpace + 1
- PosSpace = InStr(PosSpace, Text1.Text, " ")
- If PosSpace = 0 Then
- Exit Sub
- End If
- Text1.SelLength = (PosSpace - 1) - Text1.SelStart
- If Text1.SelLength = 0 Then
- GoTo TryAgain
- End If
- Else
- NotFirstTime = True
- Text1.SelStart = 0
- PosSpace = InStr(Text1.Text, " ")
- Text1.SelLength = PosSpace - 1
- End If
- End Sub
- Sub Command2_Click ()
- End
- End Sub
- Sub Command3_Click ()
- Text1.SelText = Text2.Text
- Command1.SetFocus
- End Sub
- Sub Form_Load ()
- Dim fhandle As Integer
- Dim fname As String
- fhandle = FreeFile
- fname = "c:\vbdemos\controls\inferno.txt"
- Open fname For Input As fhandle
- Text1.Text = Input(LOF(fhandle), fhandle)
- Close fhandle
- End Sub
-