3
« en: 15 de Enero 2016, 12:23 »
Hola Ogramar:
Gracias por tu respuesta, me ha servido bastante, ya casi funciona.
Me falta el detalle de capturar el Button pulsado.
Te adjunto el código.
Public Class TablaMultiplicar
Dim labelarray(10) As Label
Dim labelarray1(10) As Label
Dim buttonarray(10) As Button
Dim i, j As Integer
Private Sub TablaMultiplicar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = 290
Me.Height = 500
For i = 1 To 10
labelarray(i) = New Label
labelarray(i).BorderStyle = BorderStyle.Fixed3D
labelarray(i).Font = New Font("Arial", 10, FontStyle.Bold)
labelarray(i).Width = 40
labelarray(i).Height = 20
labelarray(i).Location = New Point(200, i * 36 + 19)
labelarray(i).ForeColor = Color.Red
labelarray(i).BackColor = Color.Cyan
labelarray(i).TextAlign = ContentAlignment.MiddleCenter
Me.Controls.Add(labelarray(i))
labelarray1(i) = New Label
labelarray1(i).Font = New Font("Arial", 10, FontStyle.Bold)
labelarray1(i).Width = 35
labelarray1(i).Height = 20
labelarray1(i).Location = New Point(120, i * 36 + 19)
labelarray1(i).ForeColor = Color.Black
labelarray1(i).BackColor = Color.DarkGray
labelarray1(i).TextAlign = ContentAlignment.MiddleCenter
labelarray1(i).Text = "x" & i
Me.Controls.Add(labelarray1(i))
buttonarray(i) = New Button
buttonarray(i).Font = New Font("Arial", 10, FontStyle.Bold)
buttonarray(i).Width = 40
buttonarray(i).Height = 25
buttonarray(i).Location = New Point(40, 19 + i * 36)
buttonarray(i).ForeColor = Color.Aquamarine
buttonarray(i).BackColor = Color.Blue
buttonarray(i).TextAlign = ContentAlignment.MiddleCenter
buttonarray(i).Text = i
Me.Controls.Add(buttonarray(i))
AddHandler buttonarray(i).Click, AddressOf All_Buttons_Clicked
Next i
End Sub
Private Sub All_Buttons_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Capturar el valor del Button pulsado
j = buttonarray(TabIndex + 5).Text
' Siempre me da valor del número que va detrás de (TabIndex + X), no del Button pulsado
Label1.Text = "Tabla del......" & j
For i = 1 To 10
labelarray(i).Text = i * j
Next i
' El resto funciona
End Sub
Private Sub Finalizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Finalizar.Click
End
End Sub
End Class