vb.net - How to get the text of the button which is clicked -


pretty new programming. i've managed come change colour of button once it's pressed. i'm trying text of button clicked on using string chosenroom, once come save, value of string nothing must doing wrong.

private sub changecolor(sender object, e eventargs)             dim senderbutton button = sender              if yellowbutton isnot nothing                  yellowbutton.backcolor = me.backcolor             end if             if senderbutton isnot yellowbutton                  senderbutton.backcolor = color.yellow                  chosenroom = senderbutton.text              end if              yellowbutton = sender          end if     end if 

this using save string

cmd1.parameters.add(new oledbparameter("room number", ctype(chosenroom, string))) 

maybe in code help. put buttons on form and...

private sub button1_click(sender object, e eventargs) handles button1.click, button2.click, button3.click         each ctr control in controls             if typeof sender button                dim mybutton button = ctype(sender, button)                 if mybutton.text = "button2"                     mybutton.backcolor = color.red                     mybutton.enabled = false                     exit                 end if              end if         next      end sub 

notice handles clause. if not responding event writing own sub pass sender argument looks responding event in case need use handles clause. boy, did not work. i'll try again

turned on option strict , didn't assuming sender button though checked typeof. had ctype mybutton.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -