• 控件作为参数传递


    控件参数传递

     

    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

     

  • 相关阅读:
    spring之通过实例工厂方法配置Bean
    spring之通过静态工厂方法配置Bean
    spring之添加后置处理器的bean的生命周期
    spring之未加后置处理器的bean的生命周期
    TreeMap源码分析——基础分析(基于JDK1.6)
    HashMap源码分析(基于JDK1.6)
    left join 和 left outer join 的区别
    开发者必备的6款源码搜索引擎
    理想的技术面试过程
    一篇学习HTTP状态码的神文:我与依依的橙色岁月
  • 原文地址:https://www.cnblogs.com/no7dw/p/1612846.html
Copyright © 2020-2023  润新知