当user第二次在文本框按回车时会提示"Type mismatch", 查了很久都不知所以然.Private Sub PPID_Text_KeyPress(KeyAscii As Integer)    Dim Retu As Long
    Dim PPID As String
    
    'KeyAscii = AscW(UCase(ChrW(KeyAscii)))
    
    On Error GoTo Input_Error
    
    If KeyAscii = vbKeyReturn Then
                
        If Len(PPID_Text.Text) > PPID_LENGTH Then
            Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
            MsgBox "This PPID is wrong!"
                        
            PPID_Text.Text = ""
            PPID_Text.SetFocus
            Exit Sub
        End If
            
        If Not Checking_Charactor(PPID_Text.Text) Then
            Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
            MsgBox "This PPID include wrong word!"
                        
            PPID_Text.Text = ""
            PPID_Text.SetFocus
            Exit Sub
        End If
        
        PPID = UCase(Trim(PPID_Text.Text))
        
        If RowCount = 0 Then
                
            Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
                                    
            PPID_Text.Text = ""
            TrackCode_Text.SetFocus
            
            Exit Sub
        
        End If
        
        Select Case Len(PPID)
        
            Case PART_NUMBER_LENGTH:
                                
                    List_PPID_VER PPID, "A00"
                    
                    PPID_Text.Text = ""
                    PPID_Text.SetFocus
                                
            Case COA_PART_LENGTH:
            
                    If Left(PPID, 1) = "0" Then
                        Version_Text.SetFocus
                        Exit Sub
                    Else
                        Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
                        MsgBox "Scanning error!"
                        
                        PPID_Text.Text = ""
                        PPID_Text.SetFocus
                    End If
                                
            Case TRACKCODE_LENGTH:
                    
                    If PPID <> TrackCode Then
                        Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
                        MsgBox "TrackCode error, please rescan!"
                        
                        PPID_Text.Text = ""
                        PPID_Text.SetFocus
                        
                        Exit Sub
                    End If
                    
                    'If Not SentFlag Then Call OK_Click
                    If Not SentFlag Then
                        
                        If Not Checking_Record Then Exit Sub
                        
                        Write_PPID
                    
                    End If
                                        
                    If Not Send_Control_Centre Then Exit Sub
                                        
                    Save_All_PPID
                    
                    Clear_Screen
                    
                    TrackCode_Text.Text = ""
                    TrackCode_Text.SetFocus
                    
            Case PPID_LENGTH:
            
                    List_PPID_VER PPID, "A00"
                    
                    PPID_Text.Text = ""
                    PPID_Text.SetFocus
                   
            Case Else:
                                
                    Retu = sndPlaySound(App.Path & "\wrong.wav", 1)
                    MsgBox "Scanning error!"
                    
                    PPID_Text.Text = ""
                    PPID_Text.SetFocus
                                        
        End Select
        
    End If
    
    Exit Sub
    
Input_Error:
    
    Log_Error Me.Name, "PPID_Text_KeyPress()", Err.Number, Err.Description    Resume NextEnd Sub

解决方案 »

  1.   

    注释On Error,看看在哪句报错
      
    *****************************************************************************
    欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码) 
    http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  2.   

    由于这个程序是在user client运行的,而且是偶尔会发生.无法在client调试.而在我这么又很难复制这个问题,请高人指点迷津!
      

  3.   

    既然不能调试,就定义一个行号嘛每一行代码后面给行号赋个值,然后在Log_Error Me.Name, "PPID_Text_KeyPress()" & 行号, Err.Number, Err.Description
    这里加上行号就知道哪里出错了