|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Command Button SequenceUsing VB.6, When a command button is clicked, the focus can be set to a text
box or a label. Is it possible to create code that requires a series of command buttons to be clicked in order to set the focus to a text box or label? Example: Click Command Button 1 then Command Button 2 to set focus to Label 1. -- Vance "Vance" <Va***@discussions.microsoft.com>'s wild thoughts were released on Mon, 10 Oct 2005 22:41:04 -0700 bearing thefollowing fruit: >Using VB.6, When a command button is clicked, the focus can be set to a text no, labels can't recieve focus.>box or a label. >Is it possible to create code that requires a series of No, because labels can't recieve focus.>command buttons to be clicked in order to set the focus to a text box or >label? Example: Click Command Button 1 then Command Button 2 to set focus to >Label 1. Are you trying to do something like this? Option Explicit Private pstrSeq As String Private Sub Command1_Click() Record "A" End Sub Private Sub Record(ButtonPressed As String) pstrSeq = pstrSeq & ButtonPressed If pstrSeq = "AB" Then MsgBox "Success" If Len(pstrSeq) = 2 Then pstrSeq = "" End Sub Private Sub Command2_Click() Record "B" End Sub Jan Hyde (VB MVP) -- In a Restaurant window: "Don't stand there and be hungry, come in and get fed up." (Bill Stebbins) [Abolish the TV Licence - http://www.tvlicensing.biz/] > >Using VB.6, When a command button is clicked, the focus can be set to a text> >box or a label. text box or> > no, labels can't recieve focus. > > >Is it possible to create code that requires a series of > >command buttons to be clicked in order to set the focus to a > >label? Example: Click Command Button 1 then Command Button 2 to set focus toShow quoteHide quote > >Label 1. The only problem I see with this approach is... how do you turn it> > No, because labels can't recieve focus. > > Are you trying to do something like this? > > Option Explicit > > Private pstrSeq As String > Private Sub Command1_Click() > Record "A" > End Sub > > Private Sub Record(ButtonPressed As String) > pstrSeq = pstrSeq & ButtonPressed > > If pstrSeq = "AB" Then MsgBox "Success" > > If Len(pstrSeq) = 2 Then pstrSeq = "" > > > End Sub > > Private Sub Command2_Click() > Record "B" > End Sub off? In other words, if the first button is pressed and then other things are done and then some time later the second button is pressed, this will rate as a successful sequence of button presses. Here's a possible alternative that uses a Timer control; it provides a 1-second window in which the two buttons must be pressed in the correct sequence. Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = False End Sub Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() If Timer1.Enabled Then MsgBox "Success" End Sub Private Sub Timer1_Timer() Timer1.Enabled = False End Sub Rick "Rick Rothstein [MVP - Visual Basic]"
<rickNOSPAMnews@NOSPAMcomcast.net>'s wild thoughts were released on Tue, 11 Oct 2005 04:18:16 -0400 bearing the following fruit: Show quoteHide quote >> >Using VB.6, When a command button is clicked, the focus can be Yea, I tried to guess as to why the OP wanted to do this. My>set to a text >> >box or a label. >> >> no, labels can't recieve focus. >> >> >Is it possible to create code that requires a series of >> >command buttons to be clicked in order to set the focus to a >text box or >> >label? Example: Click Command Button 1 then Command Button 2 >to set focus to >> >Label 1. >> >> No, because labels can't recieve focus. >> >> Are you trying to do something like this? >> >> Option Explicit >> >> Private pstrSeq As String >> Private Sub Command1_Click() >> Record "A" >> End Sub >> >> Private Sub Record(ButtonPressed As String) >> pstrSeq = pstrSeq & ButtonPressed >> >> If pstrSeq = "AB" Then MsgBox "Success" >> >> If Len(pstrSeq) = 2 Then pstrSeq = "" >> >> >> End Sub >> >> Private Sub Command2_Click() >> Record "B" >> End Sub > >The only problem I see with this approach is... how do you turn it >off? In other words, if the first button is pressed and then other >things are done and then some time later the second button is >pressed, this will rate as a successful sequence of button >presses. Here's a possible alternative that uses a Timer control; >it provides a 1-second window in which the two buttons must be >pressed in the correct sequence. > >Private Sub Form_Load() > Timer1.Interval = 1000 > Timer1.Enabled = False >End Sub > >Private Sub Command1_Click() > Timer1.Enabled = True >End Sub > >Private Sub Command2_Click() > If Timer1.Enabled Then MsgBox "Success" >End Sub > >Private Sub Timer1_Timer() > Timer1.Enabled = False >End Sub > >Rick guess was a keypad for entering an PIN. Perhaps the OP would like to rejoin this dicussion and let us in on some more details and if either of these solution has helped? Jan Hyde (VB MVP) -- Lysdexia: a peech imspediment we live to learn with. (Ed Hexter) [Abolish the TV Licence - http://www.tvlicensing.biz/] Thanks for the info so far. For lack of a better discription, what I am
trying to do is create a form that contains an array of text boxes. In order for the end user to input data into a particular text box, a series of two unique button clicks must occur. Does this help? -- Show quoteHide quoteVance "Jan Hyde" wrote: > "Rick Rothstein [MVP - Visual Basic]" > <rickNOSPAMnews@NOSPAMcomcast.net>'s wild thoughts were > released on Tue, 11 Oct 2005 04:18:16 -0400 bearing the > following fruit: > > >> >Using VB.6, When a command button is clicked, the focus can be > >set to a text > >> >box or a label. > >> > >> no, labels can't recieve focus. > >> > >> >Is it possible to create code that requires a series of > >> >command buttons to be clicked in order to set the focus to a > >text box or > >> >label? Example: Click Command Button 1 then Command Button 2 > >to set focus to > >> >Label 1. > >> > >> No, because labels can't recieve focus. > >> > >> Are you trying to do something like this? > >> > >> Option Explicit > >> > >> Private pstrSeq As String > >> Private Sub Command1_Click() > >> Record "A" > >> End Sub > >> > >> Private Sub Record(ButtonPressed As String) > >> pstrSeq = pstrSeq & ButtonPressed > >> > >> If pstrSeq = "AB" Then MsgBox "Success" > >> > >> If Len(pstrSeq) = 2 Then pstrSeq = "" > >> > >> > >> End Sub > >> > >> Private Sub Command2_Click() > >> Record "B" > >> End Sub > > > >The only problem I see with this approach is... how do you turn it > >off? In other words, if the first button is pressed and then other > >things are done and then some time later the second button is > >pressed, this will rate as a successful sequence of button > >presses. Here's a possible alternative that uses a Timer control; > >it provides a 1-second window in which the two buttons must be > >pressed in the correct sequence. > > > >Private Sub Form_Load() > > Timer1.Interval = 1000 > > Timer1.Enabled = False > >End Sub > > > >Private Sub Command1_Click() > > Timer1.Enabled = True > >End Sub > > > >Private Sub Command2_Click() > > If Timer1.Enabled Then MsgBox "Success" > >End Sub > > > >Private Sub Timer1_Timer() > > Timer1.Enabled = False > >End Sub > > > >Rick > > Yea, I tried to guess as to why the OP wanted to do this. My > guess was a keypad for entering an PIN. > > Perhaps the OP would like to rejoin this dicussion and let > us in on some more details and if either of these solution > has helped? > > > > > Jan Hyde (VB MVP) > > -- > Lysdexia: a peech imspediment we live to learn with. (Ed Hexter) > > [Abolish the TV Licence - http://www.tvlicensing.biz/] > > > Thanks for the info so far. For lack of a better discription, what I am> trying to do is create a form that contains an array of text boxes. In order> for the end user to input data into a particular text box, a series of two> unique button clicks must occur. Does this help? Instead of you asking if your description helped us, can you tellus if the code we have posted helped you? I kind of think the code I posted would be useful for what you are describing, but I am not completely sure. Rick > Does this help? You need to provide more details about what you are trying to do. In the mean time, check these properties and methods: Text1(0).SetFocus Text1(0).Locked = False ' Makes the TextBox read only You can't do Label1.SetFocus as others said. Show quoteHide quote "Vance" <Va***@discussions.microsoft.com> wrote in message news:13A79469-8E2C-422F-BEA3-EDED2A73FA4E@microsoft.com... > Thanks for the info so far. For lack of a better discription, what I am > trying to do is create a form that contains an array of text boxes. In > order > for the end user to input data into a particular text box, a series of two > unique button clicks must occur. Does this help? > -- > Vance > > > "Jan Hyde" wrote: > >> "Rick Rothstein [MVP - Visual Basic]" >> <rickNOSPAMnews@NOSPAMcomcast.net>'s wild thoughts were >> released on Tue, 11 Oct 2005 04:18:16 -0400 bearing the >> following fruit: >> >> >> >Using VB.6, When a command button is clicked, the focus can be >> >set to a text >> >> >box or a label. >> >> >> >> no, labels can't recieve focus. >> >> >> >> >Is it possible to create code that requires a series of >> >> >command buttons to be clicked in order to set the focus to a >> >text box or >> >> >label? Example: Click Command Button 1 then Command Button 2 >> >to set focus to >> >> >Label 1. >> >> >> >> No, because labels can't recieve focus. >> >> >> >> Are you trying to do something like this? >> >> >> >> Option Explicit >> >> >> >> Private pstrSeq As String >> >> Private Sub Command1_Click() >> >> Record "A" >> >> End Sub >> >> >> >> Private Sub Record(ButtonPressed As String) >> >> pstrSeq = pstrSeq & ButtonPressed >> >> >> >> If pstrSeq = "AB" Then MsgBox "Success" >> >> >> >> If Len(pstrSeq) = 2 Then pstrSeq = "" >> >> >> >> >> >> End Sub >> >> >> >> Private Sub Command2_Click() >> >> Record "B" >> >> End Sub >> > >> >The only problem I see with this approach is... how do you turn it >> >off? In other words, if the first button is pressed and then other >> >things are done and then some time later the second button is >> >pressed, this will rate as a successful sequence of button >> >presses. Here's a possible alternative that uses a Timer control; >> >it provides a 1-second window in which the two buttons must be >> >pressed in the correct sequence. >> > >> >Private Sub Form_Load() >> > Timer1.Interval = 1000 >> > Timer1.Enabled = False >> >End Sub >> > >> >Private Sub Command1_Click() >> > Timer1.Enabled = True >> >End Sub >> > >> >Private Sub Command2_Click() >> > If Timer1.Enabled Then MsgBox "Success" >> >End Sub >> > >> >Private Sub Timer1_Timer() >> > Timer1.Enabled = False >> >End Sub >> > >> >Rick >> >> Yea, I tried to guess as to why the OP wanted to do this. My >> guess was a keypad for entering an PIN. >> >> Perhaps the OP would like to rejoin this dicussion and let >> us in on some more details and if either of these solution >> has helped? >> >> >> >> >> Jan Hyde (VB MVP) >> >> -- >> Lysdexia: a peech imspediment we live to learn with. (Ed Hexter) >> >> [Abolish the TV Licence - http://www.tvlicensing.biz/] >> >> "Vance" <Va***@discussions.microsoft.com> wrote Just dropping in, the solution seems obvious to me, but in case its not> Thanks for the info so far. For lack of a better discription, what I am > trying to do is create a form that contains an array of text boxes. In order > for the end user to input data into a particular text box, a series of two > unique button clicks must occur. Does this help? I thought I would mention it. Keep a form level variable that tracks which buttons (of interest) have been pressed and set the textbox accordingly. If at some time you need to reset the combination (eg, turn it off), you simply reset the form level variable. For an example add 3 buttons and textbox to a new form and try out the code below.... LFS Option Explicit Private Completed As Long Private Sub Text1_GotFocus() If Text1.Locked Then Command1.SetFocus End Sub Private Sub Command1_Click() Completed = Completed Or 1 Text1.Locked = (Completed <> 3) End Sub Private Sub Command2_Click() Completed = Completed Or 2 Text1.Locked = (Completed <> 3) End Sub Private Sub Command3_Click() Completed = 0 Text1.Locked = True End Sub Private Sub Form_Load() Command1.Caption = "Step A" Command2.Caption = "Step B" Command3.Caption = "Cancel" Text1.Locked = True Command1.TabIndex = 0 End Sub "Larry Serflaten" <serfla***@usinternet.com> wrote in message And I'll point out that Larry's solution will not work if a specific news:OzWZSaozFHA.2132@TK2MSFTNGP15.phx.gbl... > Just dropping in, the solution seems obvious to me, but in case its not > I thought I would mention it. Keep a form level variable that tracks > which buttons (of interest) have been pressed and set the textbox > accordingly. If at some time you need to reset the combination > (eg, turn it off), you simply reset the form level variable. SEQUENCE of button presses is needed. However, if it's ANY combination of the buttons then his solution is fine. "Vance" <Va***@discussions.microsoft.com>'s wild thoughts were released on Tue, 11 Oct 2005 08:42:08 -0700 bearing thefollowing fruit: >Thanks for the info so far. For lack of a better discription, what I am It's difficult to imagine what this application does?>trying to do is create a form that contains an array of text boxes. In order >for the end user to input data into a particular text box, a series of two >unique button clicks must occur. Does this help? I mean, why this approach, why not let the user click on the textbox they want to enter data into. I'm just interested as to why you want the unique combination of button clicks. Jan Hyde (VB MVP) -- The first scientists who studied fog were mistified. (Mike Bull) [Abolish the TV Licence - http://www.tvlicensing.biz/]
Show quote
Hide quote
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message Well, it's October. I have to assume school has started in many places....news:32ipk11nlpdcsgrf0b0osjkq5662o0pg1v@4ax.com... >>Thanks for the info so far. For lack of a better discription, what I am >>trying to do is create a form that contains an array of text boxes. In >>order >>for the end user to input data into a particular text box, a series of two >>unique button clicks must occur. Does this help? > > It's difficult to imagine what this application does? > > I mean, why this approach, why not let the user click on the > textbox they want to enter data into. I'm just interested as > to why you want the unique combination of button clicks. "Jeff Johnson [MVP: VB]" <i.get@enough.spam>'s wild thoughts were released on Wed, 12 Oct 2005 11:10:37 -0400 bearing thefollowing fruit: Show quoteHide quote > Yea, I'm guessing it's a project too, but I love to see the>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message >news:32ipk11nlpdcsgrf0b0osjkq5662o0pg1v@4ax.com... > >>>Thanks for the info so far. For lack of a better discription, what I am >>>trying to do is create a form that contains an array of text boxes. In >>>order >>>for the end user to input data into a particular text box, a series of two >>>unique button clicks must occur. Does this help? >> >> It's difficult to imagine what this application does? >> >> I mean, why this approach, why not let the user click on the >> textbox they want to enter data into. I'm just interested as >> to why you want the unique combination of button clicks. > >Well, it's October. I have to assume school has started in many places.... > spec' Jan Hyde (VB MVP) -- "I'm no longer invisible" said Tom Insightfully (Jan Hyde) [Abolish the TV Licence - http://www.tvlicensing.biz/] "Vance" <Va***@discussions.microsoft.com> wrote in message Ultimately you're going to have to KEEP TRACK of which buttons were pressed news:C68FC87F-DC16-4C48-8ACE-2269FC4275CD@microsoft.com... > Using VB.6, When a command button is clicked, the focus can be set to a > text > box or a label. Is it possible to create code that requires a series of > command buttons to be clicked in order to set the focus to a text box or > label? Example: Click Command Button 1 then Command Button 2 to set focus > to > Label 1. and every time a button is pressed you'll have to check the "current sequence" to see if it's the right one. I recommend using a simple array of Longs to store this sequence. |
|||||||||||||||||||||||