There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
VB6 KeyPress beeping problem


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Nick Pudar's Avatar
Junior Member with 7 posts.
 
Join Date: May 2003
27-Oct-2004, 06:45 PM #1
VB6 KeyPress beeping problem
Hi,
I have a vexing problem that probably has a simple answer, and I'm sure this fine community knows what it is. When the following code runs in my application I get a problem that eludes me. The AnswerInput textbox is used for input, and I use the KeyPress event to trap the Enter keypress. However, whenever the user presses the enter key, my computer beeps from the speaker. The procedures that are called have not been altered at all, and this is the new code that has been added just prior to the beeping starting. The beeping seems to occur after the TestNextCard or TestShowCard procedures return to this procedure.
What is causing the beeping? And how do I turn it off?

Any help is appreciated.

Regards,
Nick
Windows XP Pro, SP2
VB6

Code:
Private Sub AnswerInput_KeyPress(KeyAscii As Integer)
If Not AdvTestingMode Then
    Exit Sub
End If
If AdvShowingMode = 1 Then
    TestingStatus.Caption = "Showing"
    If KeyAscii = 13 Then
        Guess.ZOrder
        TestNextCard
        Exit Sub
    End If
ElseIf AdvShowingMode = 0 Then
    TestingStatus.Caption = "Testing"
    If KeyAscii = 13 Then
        If (AnswerInput.Text <> Empty And _
            (Not IsNumeric(AnswerInput.Text) Or _
            Val(AnswerInput.Text) < 0 Or _
            Val(AnswerInput.Text) > 52)) Or _
            AnswerInput.Text = Empty Then
            AnswerInputKeyEntry = 99
        Else
            AnswerInputKeyEntry = Val(AnswerInput.Text)
        End If
        TestShowCard
        Exit Sub
    End If
End If
End Sub

Last edited by Nick Pudar : 27-Oct-2004 06:51 PM.
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
27-Oct-2004, 06:54 PM #2
Just before the Exit Sub add

Code:
KeyAscii = 0
Welcome to TSG.
Nick Pudar's Avatar
Junior Member with 7 posts.
 
Join Date: May 2003
27-Oct-2004, 08:42 PM #3
coderitr,
Thanks! It worked perfectly. Incidently, for my learning, why was it beeping?
Thanks again.
Nick
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
27-Oct-2004, 10:17 PM #4
Because the enter key is not valid in a text box unless the Multiline property is set = True. The operating system detected the invalid entry and reported it through a beep from the speaker. Setting KeyAscii = 0 in the KeyPress event procedure essentially cancels the key press event.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:57 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.