Event will not work when 2 classes are run

A

Aidy

I've got this code in a class
<snip>
Option Explicit
Private WithEvents m_ttHost As teemtalk.Host

Private mPassword As String
Private mWaitFor As String
Private mUser

Public Sub LogIntoHost()

Set m_ttHost = teemtalk.CurrentSession.Host
With m_ttHost
.ClearWaitFors
.Send mUser
.Send Chr(13)
.WaitFor mWaitFor
End With
End Sub

Private Sub m_ttHost_OnWaitforString(ByVal WaitFor As String)
If (WaitFor = mWaitFor) Then
m_ttHost.Send mPassword
m_ttHost.Send Chr(13)
End If

End Sub
Public Property Let WaitFor(sWaitFor As String)
mWaitFor = sWaitFor
End Property

Public Property Let User(sUser As String)
mUser = sUser
End Property

Public Property Let Password(sPassword As String)
mPassword = sPassword
End Property
<snip>

Which works fine when I instantiate it. The waitfor method waits
for a string to appear then does something

I've got antoher class with some code

<snip>
Option Explicit
Private WithEvents ttHost As teemtalk.Host

Private mSendString As String
Private mWaitFor As String

Public Sub WaitForAndEnter()

Set ttHost = teemtalk.CurrentSession.Host
With ttHost
.ClearWaitFors
.WaitFor mWaitFor
End With
End Sub

Private Sub ttHost_OnWaitforString(ByVal WaitFor As String)
If (WaitFor = mWaitFor) Then
ttHost.Send mSendString
ttHost.Send Chr(13)
End If
End Sub


Public Property Let WaitForString(sWaitFor As String)
mWaitFor = sWaitFor
End Property
<snip>

When I instantiate these two classes one after another however
the waitfor method does not work in the first instance.

Any ideas?

Aidy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top