2012-07-28 73 views
0

我必须用框架工作很多,我想知道是否可以快速设置一个框架,它是文本框,标签,进度条等......回到它们VB6中的默认值。 因为我现在唯一能做的就是自己设置框架,当我将框架的可见性设置为false时,我就可以为任何事情做好准备。设置框架,它的元素回到默认状态vb6

在此先感谢。

回答

2
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 
0

尝试for循环并遍历窗体上的每个控件以将其设置为其默认值。像这样的东西。

昏暗CTL作为在me.controls控制

每个CTL ctl.value = ctl.defaultvalue 下

干杯!

+0

首先,感谢这个答案。 但我无法得到这样的文本框的defautlvalue。 我至少有这个想法,所以再次感谢。 – Joe88 2012-07-28 08:37:41