当我点击按钮1时,MsgBox显示"1"这很好。
Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click
MsgBox(CType(sender, Button).Name.Replace("Button", ""))
End Sub
我想让MsgBox显示"30"当我点击按钮2.
Private Sub Button2_Click(sender As Object, e As RoutedEventArgs) Handles Button2.Click
Hello30()
End Sub
Sub Hello30()
'The following line is need to be repaired.
MsgBox(CType(sender, ????).Name.Replace("Hello", ""))
End Sub
不太确定你想做什么,但这是一个让你接近的例子:
Imports System.Reflection
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Hello30()
End Sub
Sub Hello30()
Dim method As String = MethodBase.GetCurrentMethod.Name
MsgBox(method.Replace("Hello", ""))
End Sub