VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "文本框、单选按钮和框架应用示例"
   ClientHeight    =   3855
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4950
   LinkTopic       =   "Form1"
   ScaleHeight     =   3855
   ScaleWidth      =   4950
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame2 
      Caption         =   "操作说明"
      Height          =   2295
      Left            =   2520
      TabIndex        =   2
      Top             =   1440
      Width           =   2295
      Begin VB.Label Label2 
         Height          =   1935
         Left            =   120
         TabIndex        =   7
         Top             =   240
         Width           =   1935
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "操作选项"
      Height          =   2295
      Left            =   120
      TabIndex        =   1
      Top             =   1440
      Width           =   2175
      Begin VB.OptionButton Option5 
         Caption         =   "选定第三行"
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   1440
         Width           =   1815
      End
      Begin VB.OptionButton Option4 
         Caption         =   "选中所有文本"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   1800
         Width           =   1695
      End
      Begin VB.OptionButton Option3 
         Caption         =   "光标在文本的末尾"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   720
         Width           =   1935
      End
      Begin VB.OptionButton Option2 
         Caption         =   "光标在第三行的开始"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   1080
         Width           =   1935
      End
      Begin VB.OptionButton Option1 
         Caption         =   "光标在文本的开始"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   360
         Width           =   1935
      End
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1095
      Left            =   120
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   120
      Width           =   4575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()
    Text1.Text = "清明时节雨纷纷，" & vbCrLf & "路上行人欲断魂；" & vbCrLf & "借问酒家何处有，" & vbCrLf & "牧童遥指杏花村。"
End Sub

Private Sub Option1_Click()
    Text1.SelStart = 0
    Text1.SetFocus
    Label2.Caption = "光标被移动到文本的起始位置。"
End Sub

Private Sub Option2_Click()
    i = 1
    n = 1
    Do While n <> 3
        If (Mid(Text1, i, 1)) <> vbLf Then
            i = i + 1
        Else
            n = n + 1
            i = i + 1
        End If
    Loop
    Text1.SelStart = i - 1
    Text1.SetFocus
    Label2.Caption = "光标被移动到文本的第三行的起始位置"
End Sub

Private Sub Option3_Click()
    Text1.SelStart = Len(Text1.Text)
    Text1.SetFocus
    Label2.Caption = "光标被移动到文本的结尾处"
End Sub

Private Sub Option4_Click()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Text1.SetFocus
    Label2.Caption = "选定了文本框中的所有字符"
End Sub

Private Sub Option5_Click()
    i = 1
    n = 1
    Do While n <> 3
        If (Mid(Text1, i, 1)) <> vbLf Then
        i = i + 1
        Else
        n = n + 1
        i = i + 1
        End If
    Loop
    Text1.SelStart = i - 1
    l = 0
    Do While (Mid(Text1, i, 1)) <> vbCr
        i = i + 1
        l = l + 1
    Loop
    Text1.SelLength = l
    Text1.SetFocus
    Label2.Caption = "选定了文本框中的第三行所有字符"
End Sub

