前端之家收集整理的这篇文章主要介绍了
vb.net 类中的伪 this对象,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Public Class Form1
Dim z As New zxl
Private Sub Form1_Click(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Click
Form2.Show()
z.setvalue("123","123",90)
z.prinf(Form2)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
z.setvalue("123",90)
'z.prinf(Me)
End Sub
Private Sub Form1_Paint(ByVal sender As Object,ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
z.prinf(Me)
End Sub
End Class
Public Class zxl
Private Structure zx
Public no As String
Public name As String
Public score As Integer
End Structure
Dim this As New zx
Public Sub setvalue(ByVal no,ByVal name,ByVal score)
this.no = no : this.name = name : this.score = score
End Sub
Public Sub prinf(ByVal frm As Form)
Dim g As Graphics = frm.CreateGraphics
Dim f As Font = New Font("楷体",30,FontStyle.Bold)
Dim br As SolidBrush = New SolidBrush(Color.Black)
g.DrawString(this.no & " " & this.name & " " & this.score,f,br,50)
End Sub
End Class