?
Solved

PRB: TextBox not recognizing KeyAscii 13

Posted on 2003-03-03
7
Medium Priority
?
465 Views
Last Modified: 2006-11-17
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
Comment
Question by:tWiZtEr_RX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8061979
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
 

Author Comment

by:tWiZtEr_RX
ID: 8062027
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
 
LVL 28

Accepted Solution

by:
AzraSound earned 300 total points
ID: 8062089
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tWiZtEr_RX
ID: 8062095
i will quadruple check
0
 

Author Comment

by:tWiZtEr_RX
ID: 8062102
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
 

Author Comment

by:tWiZtEr_RX
ID: 8062113
-- danke schon AzraSound
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 8062124
Glad I could help  :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question