我無法通過使用 class 來更改標簽顏色。 在此處輸入影像描述
Public Sub change_color()
Form1.Label1.BackColor = Color.Red
End Sub
uj5u.com熱心網友回復:
先去你的課
Public Class My_class
Public Say As String 'if you make it Dim you can't get the value by sure to make it Public
Public Function Do_somthing(ByVal Form As Form1) ' Function
Say = "Hi"
Form.Label1.Text = "Boo!"
Return True
End Function
End Class
第二去你的表格
Public Class Form1
Dim MyClass As New My_Class() ' Here to call ur class to make it easy
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Here You Call the Function
MyClass.Do_somthing(Me)
' Why (Me) because you want 'Your Class' get Full Access to Form Class
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
' Here You Call String value
Label2.Text = MyClass.Say.ToString()
End Sub
End Class
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/457044.html
標籤:VB.net
