I have built a telephone keypad using the drawing function of Excel and I would like to be able to have a visual print out in an existing Text Box of the numbers selected when I touch the individual key button Groups.

Recommended Answers

All 7 Replies

If the textbox has focus then you are done. The key presses should be translated directly to the textbox. If however, the buttons (0-9) are what you are talking about then it should be something like...

Text1.Text = Text1.Text & Command1.Caption

Good Luck

If the textbox has focus then you are done. The key presses should be translated directly to the textbox. If however, the buttons (0-9) are what you are talking about then it should be something like...

Text1.Text = Text1.Text & Command1.Caption

Good Luck

vb5prgrmr, thank you for responding to my thread. Forgive me for being an idiot, but I did not know how to use the code you suggested. Below is the code I am using for keys 1 and 2 of the telephone key pad I built. When I click on button 1 the code puts a "1" in the text box. When I click on button "2" the code replaces the "1" with a "2". This is not what I want to happen. I want to add text to the existing text so I can get a string of numbers in the text box indicating which numbers I have dialed. Here is the code.

Sub Group644_Click()
'
' Key1_Macro Macro
' Macro recorded 12/12/2009 by bg_ac_dziner
'
'
ActiveSheet.Shapes("Group 644").Select
ActiveSheet.Shapes("TextBox 656").Select
Selection.Characters.Text = "1"
With Selection.Characters(Start:=1, Length:=20).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 16
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2
End With
Range("V12").Select
End Sub


Sub Group645_Click()
'
' Key2_Macro
' Macro recorded 12/12/2009 by bg_ac_dziner
'
'
ActiveSheet.Shapes("Group 645").Select
ActiveSheet.Shapes("TextBox 656").Select
Selection.Characters.Text = "2"
With Selection.Characters(Start:=1, Length:=21).Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 16
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 2
End With
Range("V12").Select
End Sub

bg_ac_dziner

Well since I don't play with VBA all that much, I can only say that you need to make the recieving field = recieving field & new information, AKA text1.text = text1.text & newvalue

Good Luck

Well since I don't play with VBA all that much, I can only say that you need to make the recieving field = recieving field & new information, AKA text1.text = text1.text & newvalue

Good Luck

vb5prgrmr, I put "text1.text = text1.text & newvalue" in my code and I get a run time error 424 "object required". Do you know how I should go about defining the object or do you have any other suggestions?

Thanks. I appreciate your help. bg_ac_dziner

Text1 would be a control you would add to your form with the buttons and was only there as an example, because as I understand it you want to put these number into a cell directly so that would be .cell(referencetospecificcell) = .cel(ref...) or something like that. As I said before, don't play with VBA all that much and so memory fuzzy on subject.

Good Luck

Text1 would be a control you would add to your form with the buttons and was only there as an example, because as I understand it you want to put these number into a cell directly so that would be .cell(referencetospecificcell) = .cel(ref...) or something like that. As I said before, don't play with VBA all that much and so memory fuzzy on subject.

Good Luck

vb5progrmr, thank you for your help. Do you know anyone who is familiar with VBA or where I should go to get help? bg_ac_dziner

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.