当前位置:编程学习 > VB >>

vb.net 类中的伪 this对象

print?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", "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, 30, 50) 
    End Sub 
 
End Class 

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", "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, 30, 50)
    End Sub

End Class

 

 

补充:软件开发 , Vb ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,