属性 return 几个值
property return sevral value
我想从只读中获取多个值property.in下面是我的代码
Public Class Class1
ReadOnly Property Ca As New Class2
End Class
Public Class Class2
ReadOnly Property getass(q As Integer, ww As String) As Integer
Get
Codes that return q And ww
End Get
End Property
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As New Class1
Dim ret As Integer
Dim qq As Integer = Nothing
Dim qqq As String = Nothing
ret = a.Ca.getass(qq, qqq)
End Sub
End Class
我终于想要得到 qq=q 和 qqq=ww...
谢谢
您不想为此目的使用 属性。
相反,只需声明一个 Sub 来修改传递的参数,如下所示:
Public Class Class2
Sub getass(ByRef q As Integer, ByRef ww As String)
Dim _q as Integer
Dim _w as String
'do whatever you want
'then assign the final values and end sub
q = _q
ww = _ww
End Sub
End Class
然后像这样使用 sub:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As New Class1
Dim qq As Integer = Nothing
Dim qqq As String = Nothing
a.Ca.getass(qq, qqq)
'At this point your local qq and qqq will have the value setted by the getass Sub
End Sub
End Class
请注意,对于您拥有学生 ID 和姓名的最终意图,这不是一个好的设计模式。
考虑用你想要的所有属性创建一个 Class "Student" 并制作 Class2(我可以假设是教室或类似的东西)return "Student" 对象。
或者您可以使用 KeyValuePair 结构
编辑:
如果您仍想通过界面执行此操作,请尝试以下操作:
Public Class Class2
Public ReadOnly Property getass(ByRef q As Integer, ByRef ww As String) as Integer
Get
Dim _q as Integer
Dim _w as String
'do whatever you want
'then assign the final values and end sub
q = _q
ww = _ww
return ID 'ID is what you want (Integer)
End Get
End Property
End Class
我想从只读中获取多个值property.in下面是我的代码
Public Class Class1
ReadOnly Property Ca As New Class2
End Class
Public Class Class2
ReadOnly Property getass(q As Integer, ww As String) As Integer
Get
Codes that return q And ww
End Get
End Property
End Class
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As New Class1
Dim ret As Integer
Dim qq As Integer = Nothing
Dim qqq As String = Nothing
ret = a.Ca.getass(qq, qqq)
End Sub
End Class
我终于想要得到 qq=q 和 qqq=ww... 谢谢
您不想为此目的使用 属性。
相反,只需声明一个 Sub 来修改传递的参数,如下所示:
Public Class Class2
Sub getass(ByRef q As Integer, ByRef ww As String)
Dim _q as Integer
Dim _w as String
'do whatever you want
'then assign the final values and end sub
q = _q
ww = _ww
End Sub
End Class
然后像这样使用 sub:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As New Class1
Dim qq As Integer = Nothing
Dim qqq As String = Nothing
a.Ca.getass(qq, qqq)
'At this point your local qq and qqq will have the value setted by the getass Sub
End Sub
End Class
请注意,对于您拥有学生 ID 和姓名的最终意图,这不是一个好的设计模式。
考虑用你想要的所有属性创建一个 Class "Student" 并制作 Class2(我可以假设是教室或类似的东西)return "Student" 对象。
或者您可以使用 KeyValuePair 结构
编辑: 如果您仍想通过界面执行此操作,请尝试以下操作:
Public Class Class2
Public ReadOnly Property getass(ByRef q As Integer, ByRef ww As String) as Integer
Get
Dim _q as Integer
Dim _w as String
'do whatever you want
'then assign the final values and end sub
q = _q
ww = _ww
return ID 'ID is what you want (Integer)
End Get
End Property
End Class