Function CheckWord(ByVal Wrd As String) As String
        Dim i As Integer
        Dim Pos As Integer
        Dim Found As Integer
        Found = 0
        For i = 1 To 26
            Pos = InStr((Word(i).ToLower), Wrd.ToLower)
            If Pos <> 0 Then
                CheckWord = Word(i)
                Found = 1
            End If
        Next
        If Found = 0 Then
            Label2.Caption = "Not match"
        End If

   
End Function

Hmn, VB6 doesn't have the .toLower method. It uses an lcase(variablename or string) function...... try switching

Pos = InStr((Word(i).ToLower), Wrd.ToLower)

to

Pos = InStr(lcase(Word(i)), lcase(Wrd))

and see how that feels....

I tried your code and had a type mismatch error message

something is wrong with this code

Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
    
    Label1.Caption = Label1.Caption & CheckWord(Result.PhraseInfo.GetText)
End Sub

try casting it to a string..... I am trying to help you with code fragments.... I don't know how the program works together in it's entirety, but try this: Label1.Caption = Label1.Caption & CheckWord(cstr(Result.PhraseInfo.GetText))

Thanks..here is my code, can you identify my errors...

Dim WithEvents RC As SpInProcRecoContext
Dim Recognizer As SpInprocRecognizer
Dim myGrammar As ISpeechRecoGrammar
Dim Word(26) As String




  Private Sub Form_Load()
    Set RC = New SpInProcRecoContext
    Set Recognizer = RC.Recognizer
    
    Set myGrammar = RC.CreateGrammar
    myGrammar.DictationSetState SGDSActive
    
    Dim Category As SpObjectTokenCategory
    Set Category = New SpObjectTokenCategory
    Category.SetId SpeechCategoryAudioIn

    Dim Token As SpObjectToken
    Set Token = New SpObjectToken
    Token.SetId Category.Default()
    Set Recognizer.AudioInput = Token


        Word(1) = "Alpha"
        Word(2) = "Bravo"
        Word(3) = "cat"
        Word(4) = "Dog"
        Word(5) = "Echo"
        Word(6) = "Frank"
        Word(7) = "Golf"
        Word(8) = "Hotel"
        Word(9) = "India"
        Word(10) = "Jane"
        Word(11) = "Kilo"
        Word(12) = "Lima"
        Word(13) = "Mike"
        Word(14) = "North"
        Word(15) = "Oscar"
        Word(16) = "Paul"
        Word(17) = "Queen"
        Word(18) = "Romeo"
        Word(19) = "Sierra"
        Word(20) = "Tango"
        Word(21) = "Under"
        Word(22) = "Victor"
        Word(23) = "Water"
        Word(24) = "Xray"
        Word(25) = "Yoyo"
        Word(26) = "Zulu"

        
EH:
       If Err.Number Then ShowErrMsg()
   
    End Sub
    
    
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
    
   Label1.Caption = Label1.Caption & CheckWord(CStr(Result.PhraseInfo.GetText))
End Sub


EH:
        If Err.Number Then ShowErrMsg()
    End Sub
    
    
    Private Sub ShowErrMsg()
        
        ' Declare identifiers:
        Const NL As String = vbNewLine
        Dim T As String
        
        T = "Desc: " & Err.Description & NL
        T = T & "Err #: " & Err.Number
        MsgBox(T, MsgBoxStyle.Exclamation, "Run-Time Error")
        End
        
    End Sub


    
 Function CheckWord(ByVal wrd As Integer) As Integer

       
        Dim Pos As Integer
        Dim Found As Integer
        Found = 0
        For i = 1 To 26
            Pos = InStr(LCase(Word(i)), LCase(wrd))
            If Pos <> 0 Then
                CheckWord = Word(i)
                Found = 1
            End If
        Next
        If Found = 0 Then
            Label2.Caption = "Not matched"
        End If

   
End Function

End Class

Hmn, I don't have the object for voice recognition that you have...

What object??

SpInProcRecoContext, is it a third party download?

I am using micrososft's Speech SDK 5.1.
You remember the code you helped me with before (that one that works fine)..but it is using an older version of SDK not 5.1, i think it is 4 or 5.
so i couldn't find documentation.

I am trying to develop the same application using 5.1, but the documentation is confusing.

Can you point out the line that is causing the error?

This is the line that is causing the error If Err.Number Then ShowErrMsg() But when I make it as a comment

This line that is causes the error Label1.Caption = Label1.Caption & CheckWord(CStr(Result.PhraseInfo.GetText))

try breaking that up into variables.... like thetext = CStr(Result.PhraseInfo.GetText) and then call checkword(thetext), and see if that helps... also, try msgboxing result.phraseinfo.gettext, beyond that.... what is phraseinfo?

EDIT: n/m I see that phraseinfo is a part of the object for the speechlib.... try msgboxing it, and see if it returns the proper values....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.