天天看點

Visual Studio2019VB和VB6.0類(子產品)中操作窗體控件的差別

Visual Studio2019和VB6.0都建立一個Form1窗體,添加一個Button控件(VB叫Command控件)。都添加一個Class1

Visual Studio2019VB代碼:

窗體代碼

Public Class Form1
    Dim Obj As New Class1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Obj.MoveButton(Button1)
    End Sub
end Class
           

類中的代碼 

Public Class Class1
    Public Sub MoveButton(ByRef A As Button)
        A.Left = 0
    End Sub
End Class
           

VB6.0代碼:

窗體代碼

Dim obj As New Class1
Private Sub Command1_Click()
obj.MoveButton
End Sub
           

類子產品中的代碼

Public Sub MoveButton()
  Form1.Command1.Left = 0
End Sub
           

可以看出VS和VB在類(子產品)中調用窗體的控件是略有不同的

繼續閱讀