![]() |
Capture # of Button pressed to pass to another form
Hello, I have a form that has six buttons on it. I have another form that I would like to capture the button that was pressed. For instance if Bt1 is pressed I am hiding current form, opening a different form and putting 1 in a text box. Any help would be appreciated.
|
Capture # of Button pressed to pass to another form
hello,
http://www.cjoint.com/c/FHcwDJybXga ' "Module 1" '_________________________________________________ ___________ Sub OpenForm() UserForm1.Show End Sub '_________________________________________________ ___________ ' "Classe 1" '_________________________________________________ ___________ Public WithEvents cmdButton As MSForms.commandbutton Dim cmdButtonName As String Private Sub cmdButton_Click() cmdButtonName = Me.cmdButton.Caption UserForm2.TextBox1 = cmdButtonName UserForm2.Show End Sub '_________________________________________________ ___________ ' "UserForm1" '_________________________________________________ ___________ Dim x() As New Classe1 Private Sub UserForm_Initialize() Dim a As Integer For Each c In Me.Controls If TypeName(c) = "CommandButton" Then a = a + 1 ReDim Preserve x(1 To a) Set x(a).cmdButton = c End If Next End Sub '_________________________________________________ ___________ isabelle Le 2016-08-02 Ã* 13:23, jlclyde a écrit : Hello, I have a form that has six buttons on it. I have another form that I would like to capture the button that was pressed. For instance if Bt1 is pressed I am hiding current form, opening a different form and putting 1 in a text box. Any help would be appreciated. |
Capture # of Button pressed to pass to another form
hello,
I modify the code to adapt it to your demand http://www.cjoint.com/c/FHdhwtXOX6a ' "Module 1" '_________________________________________________ ___________ Sub OpenForm() UserForm1.Show End Sub '_________________________________________________ ___________ ' "Classe 1" '_________________________________________________ ___________ Public WithEvents cmdButton As MSForms.commandbutton Dim cmdButtonName As String Private Sub cmdButton_Click() cmdButtonName = Me.cmdButton.Caption n = Right(cmdButtonName, 1) UF1.TextBox1 = n UserForm1.Hide UF1.Show End Sub '_________________________________________________ ___________ ' "UserForm1" '_________________________________________________ ___________ Dim x() As New Classe1 Private Sub UserForm_Initialize() Dim a As Integer For Each c In Me.Controls If TypeName(c) = "CommandButton" Then If CDbl(Right(c.Name, 1)) = 1 And CDbl(Right(c.Name, 1)) <= 6 Then a = a + 1 ReDim Preserve x(1 To a) Set x(a).cmdButton = c End If End If Next End Sub Private Sub CommandButton7_Click() End End Sub Private Sub UserForm_Terminate() End End Sub '_________________________________________________ ___________ isabelle |
_________@@@@@@@@_____ _____@@@@@@____________ ___@@@@@@______________ __@@@@@@@_____________ ___@@@@@@______________ _____@@@@@@____________ _________@@@@@@@@_____ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ________________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___.
|
_________@@@@@@@@_____ _____@@@@@@____________ ___@@@@@@______________ __@@@@@@@_____________ ___@@@@@@______________ _____@@@@@@____________ _________@@@@@@@@_____ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ________________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___.
|
All times are GMT +1. The time now is 08:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com