Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

PRB: TextBox not recognizing KeyAscii 13

this is so weird, i have the exact same code in 2 projects, and in one, when u press enter in the textbox, the text_KeyPress KeyAscii is triggered with ascii value being 13, and in the other project, pressing Enter does absolutely nothing!
This is the code.: In project 1: Works!

Private Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then
If dacurrentIndex >= iCounter Then
Exit Sub
End If
dacurrentIndex = dacurrentIndex + 1
txtSend.Text = s_MsgRecall(iCounter - dacurrentIndex)
txtSend.SelStart = Len(txt) + 1
SendKeys "{DEL}"
End If
If KeyCode = 40 Then
If dacurrentIndex <= 0 Then
Exit Sub
End If
dacurrentIndex = dacurrentIndex - 1
txtSend.Text = s_MsgRecall(iCounter - dacurrentIndex) & Space(1)
txtSend.SelStart = Len(txt) + 1
SendKeys "{BS}"
End If
'38 = up
'40 = down
End Sub

Private Sub txtSend_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If txtSend = "" Then
        Exit Sub
    End If
    SendKeys Chr(8)
    Call cmdSend_Click
End If
End Sub

-----------
This code is in Proj. 2, DOESNT WORK WHEN ENTER IS PRESSED.
I put this line of code in the KeyDown and KeyPress events to see if they are even called and this is the code i put in: "MsgBox KeyCode", and "MsgBox KeyAscii" respectivly. It doesnt even call the messagebox. (i put breakpoints and both KeyDown or KeyAscii werent called)
-
I even put the KeyPreview on both Forms to True and False, it worked on Project 1 with both boolean values. and nothing on Project 2.
I am stumped!
0
tWiZtEr_RX
Asked:
tWiZtEr_RX
  • 4
  • 2
1 Solution
 
GPrentice00Commented:
in project two, do the keydown and keypress events fire for other keys?  Did you copy the code inside the events into the project2 events, or did you copy the whole code from the Private Sub...End Sub?  I've done that before for simplicity, but had misspelled my control name in the new project, and thus TxtGeneSeq_events in my code were never going to be fired for the TxtGenSeq textbox...

0
 
tWiZtEr_RXAuthor Commented:
Ya, KeyDown and KeyPress are triggered by other keys, even Control+Enter, (with KeyCode, it tells me that Control was pressed, then the next message box is 13(or enter),) but under no other situations (that i have found yet) can the event be triggered by Enter. And for sure hasnt been able to be triggered on its own (just pressing Enter).
and no, this is a Server and Client Project, so i didnt copy the hole code. But the textbox control was copied from the Project1(Client, the one that works), so it has same properties, and the same code is on the txtSend_KeyPress and txtSend_KeyDown because they are both called txtSend in both Projects. im so stumped.
0
 
AzraSoundCommented:
The only thing that comes to mind is that you have a command button on your form in Project2 that has its Default property set to True.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
tWiZtEr_RXAuthor Commented:
i will quadruple check
0
 
tWiZtEr_RXAuthor Commented:
THANKS SO MUCH, i expanded my form becuze i had some out of sight, and one that i copied from another program was set to Default=True!
Thanks - cant believe i overlooked the ones i couldnt see (lol :P)
0
 
tWiZtEr_RXAuthor Commented:
-- danke schon AzraSound
0
 
AzraSoundCommented:
Glad I could help  :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now