16,722
社区成员




Imports System.Reflection
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''这个是VB6.0的方法,只能调用Public的方法
CallByName(Me, "test", CallType.Method, New Object() {"abc", "def"})
''没有参数就设为nothing,有参数时就对后面的Object类型数组进行赋值
Dim s As Single = CallByName(Me, "CLOSE2", CallType.Method, Nothing)
'建议用反射
Dim mi As MethodInfo = Me.GetType.GetMethod("test", BindingFlags.Instance Or BindingFlags.Public)
mi.Invoke(Me, New Object() {"abc", "def"})
End Sub
Public Sub test(ByVal s As String, ByVal s2 As String)
Console.WriteLine(s + s2)
End Sub
Public Sub test2()
Console.WriteLine("1111111")
End Sub
Public Function CLOSE2() As Single '()
CLOSE2 = 100 ' hq(CSTJJ).SPJ / 1000
End Function
End Class
Imports System.Reflection
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''这个是VB6.0的方法,只能调用Public的方法
CallByName(Me, "test", CallType.Method, New Object() {"abc", "def"})
'建议用反射
Dim mi As MethodInfo = Me.GetType.GetMethod("test", BindingFlags.Instance Or BindingFlags.Public)
mi.Invoke(Me, New Object() {"abc", "def"})
End Sub
Public Sub test(ByVal s As String, ByVal s2 As String)
Console.WriteLine(s + s2)
End Sub
End Class