应该这么写:
Public Function AAA(Para as 数据类型) as 数据类型dim Con as control
for each Con in form1.controls
  if typeof(Con) is textbox then
        if trim(con.text)="" then 
            msgbox "...."
        end if
  end if
next '如果需要返回值则
AAA=返回值End Function
其中AAA为公用函数名,Para为参数名

解决方案 »

  1.   

    应该这么写:
    Public Sub Procdure(frmParam as Form) 
    dim Con as control
    for each Con in frmParam.controls
      if typeof(Con) is textbox then
            if trim(con.text)="" then 
                msgbox "...."
            end if
      end if
    next 
    End Sub
      

  2.   

    你可以将以下代码放入一模块中:
    Public Sub LookText(frmLook As Form)
        Dim Con As Control
        For Each Con In frmLook.Controls
          If TypeOf Con Is TextBox Then
                If Trim(Con.Text) = "" Then
                    MsgBox "....", , frmLook.Caption
                End If
          End If
        Next
    End Sub然后在需要调用的Form中用如下语句:
    LookText Me