944,093 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jul 18th, 2006
0

What is wrong with this code???

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
s0312001 is offline Offline
26 posts
since Feb 2006
Jul 18th, 2006
0

Re: What is wrong with this code???

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....
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jul 18th, 2006
0

Re: What is wrong with this code???

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
s0312001 is offline Offline
26 posts
since Feb 2006
Jul 18th, 2006
0

Re: What is wrong with this code???

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))
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jul 19th, 2006
0

Re: What is wrong with this code???

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

Reputation Points: 10
Solved Threads: 0
Light Poster
s0312001 is offline Offline
26 posts
since Feb 2006
Jul 19th, 2006
0

Re: What is wrong with this code???

Hmn, I don't have the object for voice recognition that you have...
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jul 20th, 2006
0

Re: What is wrong with this code???

What object??
Reputation Points: 10
Solved Threads: 0
Light Poster
s0312001 is offline Offline
26 posts
since Feb 2006
Jul 20th, 2006
0

Re: What is wrong with this code???

SpInProcRecoContext, is it a third party download?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jul 21st, 2006
0

Re: What is wrong with this code???

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
s0312001 is offline Offline
26 posts
since Feb 2006
Jul 21st, 2006
0

Re: What is wrong with this code???

Can you point out the line that is causing the error?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: comatose can you help
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Need some help plzzz





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC