我有 5 个按钮和 5 个标签。当我的鼠标悬停在按钮上并将其传递给文本框时,我想获得 label.text 的值。
编码
Private Sub btnRoomA_MouseHover(sender As Object, e As EventArgs) Handles btnRoomA.MouseHover
notransaksiMouse = lblTransaksiRA.Text
textbox1.text = noTransaksiMouse
End Sub
Private Sub btnRoomB_MouseHover(sender As Object, e As EventArgs) Handles btnRoomB.MouseHover
notransaksiMouse = lblTransaksiRB.Text
textbox1.text = noTransaksiMouse
End Sub
Private Sub btnRoomC_MouseHover(sender As Object, e As EventArgs) Handles btnRoomC.MouseHover
notransaksiMouse = lblTransaksiRC.Text
textbox1.text = noTransaksiMouse
End Sub
Private Sub btnRoomD_MouseHover(sender As Object, e As EventArgs) Handles btnRoomD.MouseHover
notransaksiMouse = lblTransaksiRD.Text
textbox1.text = noTransaksiMouse
End Sub
Private Sub btnRoomE_MouseHover(sender As Object, e As EventArgs) Handles btnRoomE.MouseHover
notransaksiMouse = lblTransaksiRE.Text
textbox1.text = noTransaksiMouse
End Sub
问题是我希望将所有私有子改为 1 个私有子,但我不知道.. 我试试这段代码:
Private Sub btnRoomE_MouseHover(sender As Object, e As EventArgs) Handles btnRoomA.MouseHover,btnRoomB.MouseHover,btnRoomC.MouseHover,btnRoomD.MouseHover,btnRoomE.MouseHover
notransaksiMouse = lblTransaksiRE.Text
textbox1.text = noTransaksiMouse
End Sub