控件作为参数传递

控件参数传递

 

Option Explicit
Private Sub Command1_Click()
    Dim i As Integer
    List1.Visible = True
    List2.Visible = True
    List1.ListIndex = 0
    List2.ListIndex = 0
End Sub
Private Sub Form_Load()
    List1.Visible = False
    List2.Visible = False
     With List1
        .AddItem Command1.Name
        .AddItem Check1.Name
        .AddItem List1.Name
        .AddItem List2.Name
        .AddItem Label1.Name
        .AddItem Data1.Name
    End With
    With List2
        .AddItem "0-
默认"
        .AddItem "1-箭头"
        .AddItem "2-十字线"
        .AddItem "3-I型"
        .AddItem "4-
图标 "
        .AddItem "5-
四个方向的箭头"
        .AddItem "6-右上、左下的双箭头"
        .AddItem "7-上下两个方向的双箭头"
        .AddItem "8-左上、右下双箭头"
        .AddItem "9-左右两个方向的双箭头"
        .AddItem "10-向上的箭头"
        .AddItem "11-沙漏"
        .AddItem "12-禁止记号"
        .AddItem "13-箭头和沙漏"
        .AddItem "14-箭头和问号"
        .AddItem "15-四向尺寸线"
        
  End With
  Dim bs As String
End Sub
Private Sub List1_Click()
    List2.ListIndex = 0
End Sub
Private Sub List2_Click()
     On Error Resume Next
    Select Case List1.Text
           Case Command1.Name
              Jiance Command1
           Case Check1.Name
              Jiance Check1
          Case List1.Name
              Jiance List1
          Case List2.Name
              Jiance List2
          Case Label1.Name
              Jiance Label1
          Case Data1.Name
              Jiance Data1
    End Select
End Sub
Private Sub Jiance(xx As Control)
    Select Case List2.Text
                  Case "0-默认"
                       xx.MousePointer = 0
                  Case "1-箭头"
                       xx.MousePointer = 1
                  Case "2-十字线"
                       xx.MousePointer = 2
                  Case "3-I型"
                       xx.MousePointer = 3
                  Case "4-图标 "
                       xx.MousePointer = 4
                  Case "5-四个方向的箭头"
                       xx.MousePointer = 5
                  Case "6-右上、左下的双箭头"
                       xx.MousePointer = 6
                  Case "7-上下两个方向的双箭头"
                       xx.MousePointer = 7
                  Case "8-左上、右下双箭头"
                       xx.MousePointer = 8
                  Case "9-左右两个方向的双箭头"
                       xx.MousePointer = 9
                  Case "10-向上的箭头"
                       xx.MousePointer = 10
                  Case "11-沙漏"
                       xx.MousePointer = 11
                  Case "12-禁止记号"
                       xx.MousePointer = 12
                  Case "13-箭头和沙漏"
                       xx.MousePointer = 13
                  Case "14-箭头和问号"
                       xx.MousePointer = 14
                  Case "15-四向尺寸线"
                       xx.MousePointer = 15
            End Select
End Sub

 '---------------------------------------------------------------------------------------------

 

Private Sub Command1_Click()
    example Picture1
End Sub

Public Function example(obj As VB.PictureBox) As Boolean
    MsgBox obj.Name
End Function


VBScript code

Option Explicit

Private Sub Command1_Click()

        TransPit Picture1

End Sub

 Private Sub Form_Load()

      Picture1.Picture = LoadPicture("c:\tt1.bmp")

 End Sub

 '图片控件作为参数传输

Private Function TransPit(Pit As PictureBox) As Boolean

        Set Picture2.Picture = Pit.Picture

End Function

 

VBScript code

 

'上面例子是picture1传输到picture2

 

'这个例子是image1传输到picture1

 

Option Explicit

 Private Sub Command1_Click()

      TransPit Image1

End Sub

 Private Sub Form_Load()

      Image1.Picture = LoadPicture("c:\tt1.bmp")

 End Sub

 '图片控件作为参数传输

Private Function TransPit(Pit As Image) As Boolean

        Set Picture1.Picture = Pit.Picture

End Function

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值