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







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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









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
keypress event on a userform Peter[_21_] Excel Programming 2 July 11th 05 07:25 PM
Userform Code scrabtree23[_3_] Excel Programming 3 December 5th 04 05:05 AM
excel VBA - keypress code bforster1[_7_] Excel Programming 1 July 24th 04 03:07 AM
Edit Textbox using KeyPress vba code in Access Arno Excel Programming 3 February 23rd 04 11:57 AM
VBA code for Userform Martin Los Excel Programming 4 December 5th 03 03:04 PM


All times are GMT +1. The time now is 04:07 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"