What is wrong with this code???

Reply

Join Date: Feb 2006
Posts: 26
Reputation: s0312001 is an unknown quantity at this point 
Solved Threads: 0
s0312001 s0312001 is offline Offline
Light Poster

What is wrong with this code???

 
0
  #1
Jul 18th, 2006
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Function CheckWord(ByVal Wrd As String) As String
  2. Dim i As Integer
  3. Dim Pos As Integer
  4. Dim Found As Integer
  5. Found = 0
  6. For i = 1 To 26
  7. Pos = InStr((Word(i).ToLower), Wrd.ToLower)
  8. If Pos <> 0 Then
  9. CheckWord = Word(i)
  10. Found = 1
  11. End If
  12. Next
  13. If Found = 0 Then
  14. Label2.Caption = "Not match"
  15. End If
  16.  
  17.  
  18. End Function
Last edited by s0312001; Jul 18th, 2006 at 3:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: What is wrong with this code???

 
0
  #2
Jul 18th, 2006
Hmn, VB6 doesn't have the .toLower method. It uses an lcase(variablename or string) function...... try switching
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Pos = InStr((Word(i).ToLower), Wrd.ToLower)
to
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Pos = InStr(lcase(Word(i)), lcase(Wrd))
and see how that feels....
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 26
Reputation: s0312001 is an unknown quantity at this point 
Solved Threads: 0
s0312001 s0312001 is offline Offline
Light Poster

Re: What is wrong with this code???

 
0
  #3
Jul 18th, 2006
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
Last edited by s0312001; Jul 18th, 2006 at 6:18 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: What is wrong with this code???

 
0
  #4
Jul 18th, 2006
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))
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 26
Reputation: s0312001 is an unknown quantity at this point 
Solved Threads: 0
s0312001 s0312001 is offline Offline
Light Poster

Re: What is wrong with this code???

 
0
  #5
Jul 19th, 2006
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

Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: What is wrong with this code???

 
0
  #6
Jul 19th, 2006
Hmn, I don't have the object for voice recognition that you have...
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 26
Reputation: s0312001 is an unknown quantity at this point 
Solved Threads: 0
s0312001 s0312001 is offline Offline
Light Poster

Re: What is wrong with this code???

 
0
  #7
Jul 20th, 2006
What object??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: What is wrong with this code???

 
0
  #8
Jul 20th, 2006
SpInProcRecoContext, is it a third party download?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 26
Reputation: s0312001 is an unknown quantity at this point 
Solved Threads: 0
s0312001 s0312001 is offline Offline
Light Poster

Re: What is wrong with this code???

 
0
  #9
Jul 21st, 2006
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.
Last edited by s0312001; Jul 21st, 2006 at 5:23 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: What is wrong with this code???

 
0
  #10
Jul 21st, 2006
Can you point out the line that is causing the error?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC