1

对于登录表单,我使用下面的代码将所有文本框和组合框控件的值存储在单独的工作表中,填充标签和文本框值,但是单独的组合框值不会写入单元格。谁能指出我的错误?

For Each cControl In frmLogin.Controls
If cControl.Name Like "txt*" Or cControl.Name Like "cb*" Then
    Sheet5.Cells(m, 10).Value = cControl.Tag
    Sheet5.Cells(m, 11).Value = cControl.Text
    m = m + 1
End If

下一个

4

1 回答 1

0

你必须用来MSForms做比较。

尝试这个

Dim cControl As Control
Dim m As Long

'~~> Change as applicable
m = 1

For Each cControl In frmLogin.Controls
    If TypeOf cControl Is MSForms.TextBox Or _
    TypeOf cControl Is MSForms.ComboBox Then
        Sheet5.Cells(m, 10).Value = cControl.Tag
        Sheet5.Cells(m, 11).Value = cControl.Text
        m = m + 1
    End If
Next
于 2013-08-08T05:56:28.680 回答