Hi Experts,Interesting finding, when comparing two dictionary of byte(),KeyNotFoundException throwed...
By alanwo_gmail_com
I'm thinking of purchasing a telnet emulation product written in vb.net, but I want to be able to ru...
By huffmaster
Could someone tell me how to rcord sound from a microphone and then playing it back using DirectX.Th...
By dawgfather
Hi there!I've got a question for you: I need to make an add-in function for anapplication, and t...
By fr_nk
I have been interested in making a keylogger for a while. I was successful in making one by looping...
By programmer127
I remmeber in VB6 when I did an ADO query I could read the results using the column name.. For examp...
By rudyl
Can someone point me towards informaiton about ADH in VS 2005 please? Ivaguely remember reading some...
By robintucker
I am trying to make a timer with nice gradient that you set the number of seconds, then start it co...
By kal_torak, 4 Comments
Is it possible to return a form as the output from calling a webservice. In other words, could I cre...
By overstock_com_gmail_com, 1 Comments
Is it possible to return a form as the output from calling a webservice. In other words, could I cre...
By overstock_com_gmail_com, 1 Comments
Hi. :wave: This code work great for my Form...Private Sub Form1_KeyDown(ByVal sender As Object, ByV...
By mqmin, 5 Comments
good morning everyone i've got a question i am trying to use a button from the toolbox , all bu...
By xyz777, 7 Comments
Hey, I just have a quick question about Spy++(or similar programs like the one Joacim Andersson wrot...
By hiroshi, 2 Comments
Hi All,I have asimple web service:<WebMethod()> _Public Function ReSample(ByVal sInput As Inte...
By hharry, 1 Comments
Hello, Alright. I need to whip out a Visual Basic.net application which will allow me to rec...
By aspnewguy, 2 Comments
You need to handle a keyboard event instead of a mouse event if you want to check for a particular key. Handle the KeyDown event and compare the e.KeyCode property to Keys.Enter. Intellisense will help you and you obviously already know how to create an event handler in the first place.
jmcilhinney | Tues, 04 Dec 2007 14:32:00 GMT |
I think you're going to want to use the KeyPress event rather than the click event.
Some might suggest using the LostFocus event, depending on what you are doing, but I would stay away from that event entirely, it is unreliable in my experience.
shaggyhiker | Tues, 04 Dec 2007 14:33:00 GMT |
Oh yeah, KeyDown, that's it.
shaggyhiker | Tues, 04 Dec 2007 14:34:00 GMT |
this is what i have tried
Private Sub txtname1_Enter(ByVal sender As Object, ByVal e As__
System.EventArgs) Handles txtname1.Enter
LoadStats()
End Sub
and
Private Sub txtname1_KeyDown(ByVal sender As Object, ByVal e As__
System.Windows.Forms.KeyEventArgs) Handles txtname1.ModifiedChanged
LoadStats()
End Sub
i think keydown don't work because it's if i hold down the key i want it so that as soon as i press enter it dose the LoadStat() sub
and it don't work little more detail plz
kidz14 | Tues, 04 Dec 2007 14:35:00 GMT |
Your code indicates that you are handling the ModifiedChanged event and not the KeyDown event. It doesn't matter what the procedure is called, only what's in the Handles clause. Also, I've already said that you need to test the e.KeyCode property to make sure that ENTER was the key that was depressed and there's no sign of that in your code.
jmcilhinney | Tues, 04 Dec 2007 14:36:00 GMT |
Look that one up, it has nothing to do with keypresses, but is the first event sent to the textbox when it gets focus.
What you want is to handle the KeyDown event. If you put the cursor in the sub you posted, you should be able to pick it off a list in the dropdown on the right above the code page. The keypress event receives a KeyPressEventArgs argument that has a KeyCode member. That's what you need.
KeyDown is also an option, but if the user were to hold down the key, the KeyDown event should fire every time the key repeats (according to MSDN).
shaggyhiker | Tues, 04 Dec 2007 14:37:00 GMT |
Hey, no fair, you edited your post as I was writing.
shaggyhiker | Tues, 04 Dec 2007 14:38:00 GMT |
okay for all you people that waisted my time here the anwser if you all needed it
Private Sub txtname1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtname1.KeyPress
If e.KeyChar = Chr(13) Then
LoadStats()
End If
End Sub
End Class
by the way i was just kidding i love you all for all your help by the way jmcilhinney i think you actually tried to tell me to do that but i didn't quit understand you should try pasting code every now and then
kidz14 | Tues, 04 Dec 2007 14:39:00 GMT |
And yet you still chose to do it differently: Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
LoadStats()
End If
End SubIf you use the KeyPress event then if the user holds the Enter key down the code will be executed multiple times, whereas with the KeyDown event it will be executed only once. I choose not to post code in many situations that aren't too complex because I want to encourage people to think for themselves a little. I did say handle the KeyDown event and compare e.KeyCode to Keys.Enter. That seems pretty explicit to me.
jmcilhinney | Tues, 04 Dec 2007 14:40:00 GMT |
i know but i didn't quite know how to use the e. thingy untill now but thanks learned something new cause of you :D
kidz14 | Tues, 04 Dec 2007 14:41:00 GMT |
This seems surreal. I was reading something on MSDN about what I thought was KeyPress, but when I went back to confirm it, I have a different set of text. The current thing I am reading says that KeyPress only receives character keys, so Enter would not be used. KeyDown is the ONLY one that will work. I wonder what I was reading before that showed that KeyDown would repeat, and KeyPress would not?
I believe Chr() is in the VisualBasic namespace, which some people here are opposed to. It is also ASCII, while .NET is fundamentally Unicode (though you can do either one, the emphasis is on Unicode). For those reasons, jmcilhinney (whoes name I will butcher in the spelling, no doubt) has a slightly better solution.
shaggyhiker | Tues, 04 Dec 2007 14:42:00 GMT |
keypress actually dose work so ya check b 4 you talk
kidz14 | Tues, 04 Dec 2007 14:43:00 GMT |
I don't recall posting that the KeyPress event wouldn't work. What I said was that it will be raised multiple times if the user holds the key down, whereas KeyDown will only be raised once each time the key is depressed. If it is acceptable or desirable that your LaodStats method be called multiple times in that circumstance then using the KeyPress event is fine. If not then you should be handling the KeyDown event as I suggested. Also, to stick with Unicode you should use ChrW or, preferably, Convert.ToChar.
jmcilhinney | Tues, 04 Dec 2007 14:45:00 GMT |