我必须在框架上做很多工作,我想知道是否可以快速设置一个框架,它的文本框、标签、进度条等......回到它们在 VB6 中的默认值。因为我现在唯一能做的就是在我将框架的可见设置为 false 时自己设置它们,所以我可以做任何事情。
提前致谢。
Option Explicit
'~~~ When a button is clicked..
Private Sub Command1_Click()
Dim cntl As Control
For Each cntl In Me.Controls '~~~ Loop through all the controls in the form
If TypeOf cntl Is TextBox Then '~~~ if the control is a TextBox..
cntl.Text = "" '~~~ ..set the Text as empty
ElseIf TypeOf cntl Is ComboBox Or TypeOf cntl Is ListBox Then '~~~ if the control is ComboBox/ListBox..
cntl.Clear '~~~ ..clear the items
ElseIf TypeOf cntl Is CheckBox Then '~~~ if the control is a CheckBox..
cntl.Value = vbUnchecked '~~~ ..uncheck it
ElseIf TypeOf cntl Is OptionButton Then '~~~ if the control is an OptionButton(radio buttons)..
cntl.Value = False '~~~ ..set it's value to False
End If
Next
End Sub
尝试一个 for 循环并遍历表单上的每个控件以将其设置为默认值。像这样的东西。
将 Ctl 作为控件进行调暗
对于 me.controls 中的每个 Ctl ctl.value = ctl.defaultvalue next
干杯!