引用參考來源
---
Class1.vb
Public Class Class1
Inherits TextBox '繼承TextBox
Public Sub msg(ByVal x As String) '建立一個Class1的方法
MsgBox(x) '顯示MsgBox
End Sub
End Class
Form1.vb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Class11 As New Class1
Class11.Text = "Hello! VB2005." '在Class1顯示文字
Dim x As String = Class11.Text
Class11.msg(x) '會跑出MsgBox(新增的方法,並非TextBox原本有的方法)
End Sub
End Class
沒有留言:
張貼留言