控件中,有没有命令代替TEXT1如 ME.TEXT  但ME是代表表单,有什么命令可代表控件?

解决方案 »

  1.   

    Me.Controls("text1").Text = " asfs"
      

  2.   

    Me.Controls(0).Text = "asfs"
      

  3.   

    哦,我的意思是这样,因为我要指定每个控件只能录入日期,如下代码
    If Text2.Text <> "" Then
        If IsDate(Text2.Text) = True Then
            Text2.Text = Format(Text2.Text, "YYYY.MM.DD")
        Else
           CACABA = MsgBox("日期格式错误", 0, "注意")
           Cancel = True
        End If
    End If
    这样的话我复制到每个控件都要修改,因为别的表单的话控件名可能为TEXT3,有没有什么简便方法?
      

  4.   

    dim me as new text1
    sub()
    me.text=""
    ...
    end sub
      

  5.   

    你用控件数组就可以只写一次代码,如txtInput(1),txtInput(2)....
      

  6.   

    with txtInput(index)
         If .Text <> "" Then
             If IsDate(.Text) = True Then
                 .Text = Format(.Text, "YYYY.MM.DD")
             Else
                 CACABA = MsgBox("日期格式错误", 0, "注意")
                 Cancel = True
             endif
         End If
    End With