| | |
How can is see what button is pressed in a button array
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 13
Reputation:
Solved Threads: 0
I got a button array of 40 buttons
And i handle all the button events in 1 sub .
But i need to know what button is pressed.
Can someone help me ?
And i handle all the button events in 1 sub .
But i need to know what button is pressed.
Can someone help me ?
VB.NET Syntax (Toggle Plain Text)
Private bttonArray(41) As Button Public Sub Hoofdscherm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load REM place the Buttons in a array bttonArray(1) = Button1 bttonArray(2) = Button2 bttonArray(3) = Button3 bttonArray(4) = Button4 bttonArray(5) = Button5 bttonArray(6) = Button6 bttonArray(7) = Button7 bttonArray(8) = Button8 bttonArray(9) = Button9 bttonArray(10) = Button10 bttonArray(11) = Button11 bttonArray(12) = Button12 bttonArray(13) = Button13 bttonArray(14) = Button14 bttonArray(15) = Button15 bttonArray(16) = Button16 bttonArray(17) = Button17 bttonArray(18) = Button18 bttonArray(19) = Button19 bttonArray(20) = Button20 bttonArray(21) = Button21 bttonArray(22) = Button22 bttonArray(23) = Button23 bttonArray(24) = Button24 bttonArray(25) = Button25 bttonArray(26) = Button26 bttonArray(27) = Button27 bttonArray(28) = Button28 bttonArray(29) = Button29 bttonArray(30) = Button30 bttonArray(31) = Button31 bttonArray(32) = Button32 bttonArray(33) = Button33 bttonArray(34) = Button34 bttonArray(35) = Button35 bttonArray(36) = Button36 bttonArray(37) = Button37 bttonArray(38) = Button38 bttonArray(39) = Button39 bttonArray(40) = Button40 For x = 1 To 40 AddHandler bttonArray(x).Click, AddressOf Button_Click bttonArray(x).Show() bttonArray(x).Size = New Size(80, 23) Next x End Sub Rem button click sub Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Rem now i need to know then button number bttonArray(This number i need).Text = "click" End Sub
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Sep 2009
Posts: 13
Reputation:
Solved Threads: 0
Thank You for you quick reply.
It works , i see the clicked button change .
But i still not know how to get the number of the button.
I tryed several things but i keep freezing my program.
Can you maybe explain , how i can place the button number in a integer ?
It works , i see the clicked button change .
But i still not know how to get the number of the button.
I tryed several things but i keep freezing my program.
Can you maybe explain , how i can place the button number in a integer ?
Last edited by Ulukay; Sep 9th, 2009 at 7:12 am.
By comparing references,
EDIT:
variable name changed.
VB.NET Syntax (Toggle Plain Text)
Dim btn As Button = CType(sender, Button) Dim i As Integer For i = 0 To bttonArray.Length - 1 If btn.Equals(bttonArray(i)) Then 'statements End If Next
EDIT:
variable name changed.
Last edited by adatapost; Sep 9th, 2009 at 7:33 am. Reason: variable name changed.
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- how to create array of button in C# (C#)
- Media Player Interface (C#)
- Problem changing contents of JTable when button is pressed... (Java)
- How can I know the button is pressed? (Visual Basic 4 / 5 / 6)
- How to determine which button was pressed? (JavaScript / DHTML / AJAX)
- stopping code executing if cancel button pressed on msgbox (VB.NET)
- How to open a dialogue box and loads a file, when button is pressed in ms-access (Visual Basic 4 / 5 / 6)
- Java Swing Calculator program not running. It has 0 errors (Java)
- Recognizing when a button is pressed. (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Ribbon dll problem
- Next Thread: Delete Blank line(s) from a textbox?
| Thread Tools | Search this Thread |
access account advertising append array arrays assembly basic botnet box buttons byte c# c++ cast char character click convert cookies coordinates count counttheoccurenceofanintegerinthe10inputs data database decryption delete dialog dropdown dynamic encryption exception fade file forms fraud frequency fstream function graph histogram image index input inputs int integer intersect java javascript list listbox loops math memory menu multi multidimensional mysql news number occurence opacity output overwrite panel parse perl php physics pointer ppc problem programming python radio read reference robot save scanner search sequential sql string strings table text time transfer transparency troubleshoot txt upload variable vb vbnet visualbasic.net visualstudio2008 web







