+ Reply to Thread
Results 1 to 2 of 2

keypress on a userform (with code)

  1. #1
    Peter
    Guest

    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" <[email protected]> schreef in bericht
    news:%[email protected]...
    > have you got some code to share?
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Peter" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:%23yR60%[email protected]...
    > 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" <[email protected]> schreef in bericht
    > news:%[email protected]...
    > > have you got some code to share?
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > "Peter" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1