473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What the deal?

buc
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses are
true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC
Nov 21 '05 #1
6 1339
Hi,

Textbox.focus will return true if the textbox recieves focus. I
think the property you are looking for is focused.

http://msdn.microsoft.com/library/de...focustopic.asp

http://msdn.microsoft.com/library/de...cusedtopic.asp

Ken
-------------------
"buc" <bu******@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses are
true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC

Nov 21 '05 #2
How can you name your A button A & so on?

Why have you got both Username & Password focus to true at the same time?

I am slightly confused by your post. Please clarify

"buc" wrote:
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses are
true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC

Nov 21 '05 #3
buc
According to MSDN .focus sets focus OR returns a true/false as to
whether a control has focus or not. Im am simply checking what textbox
currently has focus to know where to put the alphabetic letter that they
user just pressed. I can't figure out why this code is failing, How can 2
controls have focus at the same time.? Event if I do a a txtUser.Focus(),
which actually sets focus, it code still returns that both have focus.. Any
ideas... I couldn't find a FOCUSED command..

"buc" <bu******@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named
A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses
are true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC

Nov 21 '05 #4
buc
Never mind, I found the focused in the MSDN, but it is not an available
option when I type txtUser. , only FOCUS shows up. If I hand jam the
..FOCUSED method, it doesn't error out though. Wow, thats weird.. I guess I
got focus mixed up. It works fine now.. Just couldn't find the .focused in
the intellisense. Thanks

"buc" <bu******@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named
A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses
are true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC

Nov 21 '05 #5
Hi,

In the visual studio options->text editor->basic uncheck the hide
advanced members check box. The code you are using set the focus to the
first textbox then sets the focus to the second textbox. Actually since you
are clicking on a button to add to textbox the button has the focus. Try
something like this

Dim bPassword As Boolean = False

Private Sub txtUser_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtUser.TextChanged

bPassword = False

End Sub

Private Sub txtPassword_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtPassword.TextChanged

bPassword = True

End Sub

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If bPassword Then
txtUser.Text = txtUser.Text & UCase(CType(sender, Button).Text)
Else
txtPass.Text = txtPass.Text & UCase(CType(sender, Button).Text)
End if

End Sub
Ken
----------------------------
"buc" <bu******@hotmail.com> wrote in message
news:eE*************@TK2MSFTNGP10.phx.gbl...
According to MSDN .focus sets focus OR returns a true/false as to
whether a control has focus or not. Im am simply checking what textbox
currently has focus to know where to put the alphabetic letter that they
user just pressed. I can't figure out why this code is failing, How can 2
controls have focus at the same time.? Event if I do a a txtUser.Focus(),
which actually sets focus, it code still returns that both have focus.. Any
ideas... I couldn't find a FOCUSED command..

"buc" <bu******@hotmail.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I have created a simple login keyboard with QWERTY keys with a user textbox
and password textbox. When I press a key the text goes into both boxes....?
The focus event on both boxes eval to TRUE. Why? this is driving me nuts,
must be a simple answer. Here's code
I named each letter button its own letter (The 'A' button is named
A..Etc.)
I shortened the A.Click, B.click code handles for this post because there
were 26 of them.

Private Sub Q_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Q.Click, W.Click, E.Click, R.Click, T.Click,
Y.Click............rest of them

If txtUser.Focus = True Then txtUser.Text = txtUser.Text &
UCase(CType(sender, Button).Text)
If txtPass.Focus = True Then txtPass.Text = txtPass.Text &
UCase(CType(sender, Button).Text)

End Sub
The letter is put in both boxes, and even the DEBUGGER says both focuses
are true?? This is the only code in my program right now..
Any Ideas?..... Thanks BUC


Nov 21 '05 #6
Focus is a method, not a property. It returns true if the control
successfully receives focus. To see if a control has the focus, use
the Focused property. As Ken said, go into the options for VB and
uncheck the "Hide Advanced Members" option. Then Focused will be seen
in intellisense.

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
15
by: barry womb | last post by:
Hello- This is my first post, thank you. I've recently purchased the Sams "Teach Yourself MySQL in 21 Days". Per the lessons, I installed MySQL on my Windows XP machine. Things seemed to be...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
10
by: G Matthew J | last post by:
interesting "signal vs. noise" blog entry: http://37signals.com/svn/archives2/whats_wrong_with_ajax.php
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
48
by: Frederick Gotham | last post by:
The "toupper" function takes an int as an argument. That's not too irrational given that a character literal is of type "int" in C. (Although why it isn't of type "char" escapes me... ) The...
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
8
by: Nick | last post by:
Hi there, Membership.GetNumberOfUsersOnline() works great the first time, then jumps up to the number of users registered in the system. I have tried enumerating through each user individually...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.