亲爱的我的子
Dim onThisTable as String ="Name" Private Sub skill_mouseHover(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.MouseHover,button2.MouseHover,panel1.MouseHover,panel2.MouseHover,pBox1.MouseHover descriptionLabel.Text = dbClass.getDescription(sender.Text,onThisTable) End Sub
现在,我希望根据用户传递的内容(面板或一个pBox或一个按钮)给onThisTable一个不同的值,但是我无法找到什么是正确的方式来比较它是什么类型的?
Private Sub skill_mouseHover(ByVal sender As System.Object,pBox1.MouseHover if sender is ( a button ) onThisTable = "Admin" else if sender is ( a panel ) onThisTable = "dbObject" else onThisTable ="Name" end if descriptionLabel.Text = dbClass.getDescription(sender.Text,onThisTable) End Sub
您可以在此处使用TypeOf关键字作为描述(
link)
If TypeOf sender Is Button Then onThisTable = "Admin" ElseIf TypeOf sender Is System.Windows.Forms.Panel Then onThisTable = "dbObject" Else onThisTable = "Name" End If