MatchEntry 属性和选项按钮控件示例
下例用 MatchEntry 属性,演示组合框和列表框可用的字符匹配。该示例中,用户可以设置与选项按钮控件匹配的类型,然后键入到组合框中,以便在列表中指定一项。
窗体包含:
- 名为 OptionButton1 到 OptionButton3 的三个选项按钮控件。
- 名为 ComboBox1 的组合框。
Sub UserForm_OptionButton1_Click()
UserForm_ComboBox1.MatchEntry = 2
End Sub
Sub UserForm_OptionButton2_Click()
UserForm_ComboBox1.MatchEntry = 0
End Sub
Sub UserForm_OptionButton3_Click()
UserForm_ComboBox1.MatchEntry = 1
End Sub
Sub UserForm_Initialize()
Dim i
For i = 1 To 9
UserForm_ComboBox1.AddItem "Choice " & i
Next
UserForm_ComboBox1.AddItem "Chocoholic"
UserForm_OptionButton1.Caption = "No matching"
UserForm_OptionButton1.Value = True
UserForm_OptionButton2.Caption = "Basic matching"
UserForm_OptionButton3.Caption = "Extended matching"
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27