文本实例
Private Sub Command1_Click()
For i = 0 To 2
If Option1(i).Value = True Then
Text1.FontName = Option1(i).Caption
End If
Next i
If Option4(0).Value = True Then Text1.ForeColor = vbRed
If Option4(1).Value = True Then Text1.ForeColor = vbYellow
If Option4(2).Value = True Then Text1.ForeColor = vbBlue
For i = 0 To 2
If Option7(i).Value = True Then
Text1.FontSize = Val(Option7(i).Caption)
End If
Next i
Text1.FontBold = Check1.Value
Text1.FontItalic = Check2.Value
Text1.FontUnderline = Check3.Value
Text1.FontStrikethru = Check4.Value
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
列表操作1
Private Sub Command1_Click()
Dim x As String
x = InputBox("请输入城市名称", , 0)
List1.AddItem x
Label3.Caption = "新添加的项目为" & List1.List(List1.ListCount - 1)
Label1.Caption = "列表中项目数为:" & List1.ListCount & "个"
End Sub
Private Sub Form_Load()
Command1.Caption = "添加城市"
Label1.Caption = "列表中项目数为:" & List1.ListCount & "个"
End Sub
Private Sub List1_Click()
Label2.Caption = "您选择的城市为:" & List1.List(List1.ListIndex)
End Sub
列表操作2
Dim i As Integer
Private Sub Command1_Click()
If List1.ListIndex = -1 Then
MsgBox "请选择项目"
Exit Sub
End If
For i = 1 To 20
If List1.List(List1.ListIndex) = List2.List(i) Then
MsgBox "该项目已添加"
Exit Sub
End If
Next i
List2.AddItem List1.ListIndex
End Sub
Private Sub Command2_Click()
If List2.ListIndex = -1 Then
MsgBox "请选择要移除的项目"
Exit Sub
End If
List2.RemoveItem Index
End Sub
Private Sub Command3_Click()
If MsgBox("确定清空?", 4) = vbYes Then List2.Clear
End Sub
Private Sub Command4_Click()
List1.AddItem "Item" & i
i = i + 1