整个表单上有若干的控件(有文本框、命令按钮等)和一个picturebox控件,但现在不知道picturebox控件的name属性,如何通过程序查出此picturebox的name属性?

解决方案 »

  1.   

    dim ctl as controlfor each ctl in me.controls
        msgbox ctl.name
    next
      

  2.   

    for each ctl in me.controls
        msgbox ctl.name
    next
    若单用一名msgbox ctl.name则所有控件的名称都要显示一遍
    可不可以用一句:if ctl是picturebox then msgbox ctl.name呢
    如果可以,这句话如何写呢???
      

  3.   

    dim ctrl as control
    dim ctrltype as string
    for each ctl in me.controls
        ctltype = typename(ctl)
        if ctltype = "picture" then
            msbox ctl.name
        end if
    next
      

  4.   

    Private Sub Command1_Click()
      Dim pic As PictureBox
      On Error Resume Next
      For Each pic In Form1
        Print pic.Name
      Next pic
    End Sub