| | |
How can is see what button is pressed in a button array
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved | View First Unread |
•
•
Join Date: Sep 2009
Posts: 15
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
•
•
Join Date: Sep 2009
Posts: 15
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.
0
#8 ' ********************************************
' ** Button clicked so carry out the event **
' ********************************************
' ** Button clicked so carry out the event **
' ********************************************
VB.NET Syntax (Toggle Plain Text)
Private Sub btnEvents_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Click Dim cString As String = sender.Text() 'Dim myObject As Object = sender Select Case cString Case "Add" ....
Last edited by adatapost; 8 Hours Ago at 7:31 am. Reason: Added [code] tags. Encase your code in: [code] and [/code]
![]() |
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: Button Array
- Next Thread: global mouse over event
| Thread Tools | Search this Thread |
access advertising append applet arc array arrays basic binarysearchtree botnet button buttons byte c# c++ char character class click convert cookies coordinates count data database decryption delete dialog dropdown dynamic exception file files forms fraud frequency fstream function garbage graph histogram image index input inputs int integer intersect java javascript jsp list listbox math memory menu multidimensional mysql news number occurence opacity output overwrite parameter parse perl php physics pointer ppc problem program programming python radio random recursion reference save scanner search sequential split sql string textbox time transfer transparency troubleshoot upload user values variable vb vbnet visualbasic.net visualstudio2008 web








