Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default 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
  #4   Report Post  
Junior Member
 
Posts: 2
Default

_________@@@@@@@@_____ _____@@@@@@____________ ___@@@@@@______________ __@@@@@@@_____________ ___@@@@@@______________ _____@@@@@@____________ _________@@@@@@@@_____ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ________________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___.
  #5   Report Post  
Banned
 
Posts: 3
Default

_________@@@@@@@@_____ _____@@@@@@____________ ___@@@@@@______________ __@@@@@@@_____________ ___@@@@@@______________ _____@@@@@@____________ _________@@@@@@@@_____ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ___________________________ ______@@@@@@@@@_______ __@@@@@_______@@@@@__ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ _@@@@@_________@@@@@_ __@@@@@_______@@@@@__ ______@@@@@@@@@_______ ________________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@________________ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___ __@@@@@@@@@@@@@@___.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close user form when button is pressed april27 Excel Programming 1 June 16th 06 11:03 AM
preventing button being pressed Mike Excel Discussion (Misc queries) 2 March 16th 06 03:47 PM
Can't select macro button after other button is pressed C. Campbell Excel Programming 1 November 30th 04 07:46 PM
Which button was pressed? Adrian[_4_] Excel Programming 7 April 28th 04 04:55 PM
Errormessage when button is pressed twice or more Pointerman Excel Programming 4 April 7th 04 03:56 PM


All times are GMT +1. The time now is 12:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"