利用 this.Controls, 动态存取物件
Private Sub palH_BtnX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles btnH01.Click, btnH02.Click
'利用 this.Controls, 动态存取物件 ' this 必须是容器 btnSender = CType(sender, Button).Name
strIdx = Strings.Right(btnSender, 2)
txtSender = CType(palH.Controls("txtH" & strIdx), TextBox).Text
'btnSender = CType(sender, Button).Name
'Select Case btnSender
' Case "btnH01" ' txtSender = txtH01.Text ' Case "btnH02" ' txtSender = txtH02.Text ' Case Else ' ' nothing 'End Select
End Sub