Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP: LISTBOX INSTEAD OF AN TEXTBOX

Status
Not open for further replies.

Cballe

Programmer
Apr 14, 2002
16
0
0
ZA
HI there guys,
I need help with the following please: The code below is code that is written for a Speech Recognition program. When the user speaks thru a microphone, the code below is triggered and the speech that is recognized is displayed in a textbox. The problem that I have is that I don’t want the text to be displayed in a textbox (txtSpeech in the case below), I want the text to be displayed in a Listbox. The reason why I want the text to be displayed in a ListBx, is because I have developed a
function that compares the text of two ListBoxes –the only problem is that the compare function works great when making use of two ListBoxes, but in this case, the text is displayed in a TextBox…The text that must be change (BELOW) is written in Italics to give you an indication of which code (I think) should change in order to let the text be displayed in a ListBox instead of an Textbox. The name of the textbox used is txtSpeech in the code below. So all I want is for you guys to help me by just give me an indication of how the code should look like when one make use of a ListBox. It is only three lines of code that must be changed – so please guys, I don’t want you to develop my code for me, I am a newbie an are still finding me feet in Visual Basic, so I would appreciate it very much if you could help me with the code, because it is the only way how I could see how to implement a ListBox to do the same function as the TextBox in the code below… Here is the code:


' This function handles Recognition event from the reco context object.
' Recognition event is fired when the speech recognition engines recognizes
' a sequences of words.

Private Sub RecoContext_Recognition(ByVal StreamNumber As Long, _
ByVal StreamPosition As Variant, _
ByVal RecognitionType As SpeechRecognitionType, _
ByVal Result As ISpeechRecoResult _
)
Dim strText As String
strText = Result.PhraseInfo.GetText
Debug.Print "Recognition: " & strText & ", " & _
StreamNumber & ", " & StreamPosition

· Now below is the part of the code that must change in order to make use of a ListBox instead of an TextBox (I am not sure if anything above should change also?):
' Append the new text to the text box, and add a space at the end of the
' text so that it looks better

txtSpeech.SelStart = m_cChars
txtSpeech.SelText = strText & " "
m_cChars = m_cChars + 1 + Len(strText)
End Sub

Thanks for your help and precious time…
Best Regards
C-Power
 
Hi,

You have to decide what the criterium is for changing to a new item in the list. Is it everytime Sub RecoContext_Recognition is called?
If so, then its easy:

------------------------------
list1.additem strText
------------------------------

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
also, if you add this line after the .additem, the list box will scroll so the last line entered will always be visible:

list1.topindex=list1.newindex
nick bulka

 

Hi guys,

Thanks for the help, but there is still a problem, don’t know what I did wrong, but it is as follows:

I have replaced the code:

txtSpeech.SelStart = m_cChars
txtSpeech.SelText = strText & " "
m_cChars = m_cChars + 1 + Len(strText)

With this (like you have said)

list1.additem strText

It works beautifully, but the only problem is that it only fills the ListBOx half in sentence and then continues onto the next line although there is still enough space to fit in the words:

What I mean is that say for instance the ListBox`s width =120mm and it could accommodate approximately 10 words per sentence. In this case, it only put three or four words per line and then continues beneath the first sentence

Could someone help please?

Thanks guys
Regards
C.P.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top