ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   keypress on a userform (with code) (https://www.excelbanter.com/excel-programming/334491-keypress-userform-code.html)

Peter[_21_]

keypress on a userform (with code)
 
Yes I do. Here it is. (BTW Sorry to not include it in my first post)

<Beginning of code in the module for the Userform

Option Explicit
Const CONCERNING As String = "Concerning: "
Const OPTIONBUTTON1TXT As String = "optionbutton 1 text "
Const OPTIONBUTTON2TEXT As String = "optionbutton 2 text "
Dim sConcerning As String


Private Sub tbNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If obOptionButtonOne Then
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
Else
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
End If
tbReference = sConcerning
End Sub


Private Sub obOptionBttn1_Click()
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
tbNumber.SetFocus
End Sub


Private Sub obOptionBttn2_Click()
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
tbNumber.SetFocus
End Sub

<End of code

Greetings,

Peter


"Bob Phillips" schreef in bericht
...
have you got some code to share?

--
HTH

Bob Phillips

"Peter" wrote in message
...
Hello everyone,



So far I've managed to get a textbox updated when typing characters in
another textbox. Unfortunately, there are drawbacks that I can't get rid

of.
Maybe someone can help me.



Textbox: tbNumber

This textbox is part of the source for the textbox that follows shortly.
When typing a number into tbNumber, I want that number to become visible

in
the tbReference textbox with each character has just been typed.



Textbox: tbReference

The text in this textbox is a string variable consisting of a standard

text
combined with a word that is put in the variable based on the selection
of

1
of 2 option buttons and the number typed in tbNumber.




Things that work and things that do not (yet?) work:

When starting to type something into tbNumber the first character appears
only after the second one is typed.

Another thing that does not (yet?) work is pressing "backspace" to delete
the last character.

And choosing the other option does not cause immediate adjustment of the
string shown in tbReference.



Maybe someone knows how to handle this.



Greetings,

Peter








Bob Phillips[_7_]

keypress on a userform (with code)
 
Peter,

How about this

Option Explicit

Const CONCERNING As String = "Concerning: "
Const OPTIONBUTTON1TXT As String = "optionbutton 1 text "
Const OPTIONBUTTON2TXT As String = "optionbutton 2 text "
Dim sConcerning As String

Private Sub tbNumber_Change()
If obOptionBttn1 Then
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
Else
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
End If
tbReference = sConcerning
End Sub


Private Sub obOptionBttn1_Click()
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
tbNumber.SetFocus
End Sub


Private Sub obOptionBttn2_Click()
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
tbNumber.SetFocus
End Sub




--
HTH

Bob Phillips

"Peter" wrote in message
...
Yes I do. Here it is. (BTW Sorry to not include it in my first post)

<Beginning of code in the module for the Userform

Option Explicit
Const CONCERNING As String = "Concerning: "
Const OPTIONBUTTON1TXT As String = "optionbutton 1 text "
Const OPTIONBUTTON2TEXT As String = "optionbutton 2 text "
Dim sConcerning As String


Private Sub tbNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If obOptionButtonOne Then
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
Else
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
End If
tbReference = sConcerning
End Sub


Private Sub obOptionBttn1_Click()
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
tbNumber.SetFocus
End Sub


Private Sub obOptionBttn2_Click()
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
tbNumber.SetFocus
End Sub

<End of code

Greetings,

Peter


"Bob Phillips" schreef in bericht
...
have you got some code to share?

--
HTH

Bob Phillips

"Peter" wrote in message
...
Hello everyone,



So far I've managed to get a textbox updated when typing characters in
another textbox. Unfortunately, there are drawbacks that I can't get

rid
of.
Maybe someone can help me.



Textbox: tbNumber

This textbox is part of the source for the textbox that follows

shortly.
When typing a number into tbNumber, I want that number to become

visible
in
the tbReference textbox with each character has just been typed.



Textbox: tbReference

The text in this textbox is a string variable consisting of a standard

text
combined with a word that is put in the variable based on the selection
of

1
of 2 option buttons and the number typed in tbNumber.




Things that work and things that do not (yet?) work:

When starting to type something into tbNumber the first character

appears
only after the second one is typed.

Another thing that does not (yet?) work is pressing "backspace" to

delete
the last character.

And choosing the other option does not cause immediate adjustment of

the
string shown in tbReference.



Maybe someone knows how to handle this.



Greetings,

Peter











All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com