VB 6.0 - object variable not set - Asked By Shashi R on 07-Mar-06 06:28 PM

When I tried to execute the below code I am getting an "Error 91. object variable or with block variable not set" (at Assigning the values to local variables). I read couple of articles but i couldnt understand why i am getting in my case.
I have created an object also have a valid refernce assigned to it. Also I added the required refernces for the project

can any one  help me with this

Thanks
 
[CODE]
Private mGoogle As New Google
Private Msg As String
Public oXMLDoc As DOMDocument40

'************************************************************* 

Public Sub Main(ByVal Msg As String, ByVal XML As String)
 
  Set oXMLDoc = New DOMDocument40
    oXMLDoc.loadXML (strXML)
  
    Select Case Msg
      Case "google"           
       ToGoogle
      Case "Yahoo"          
       ToYahoo
      
End Sub

'****************************************************************

Private Function ToGoogle() As String

    Dim Search As String
    Dim Time As String
     
'XML Node variables
 Dim xSearch  As IXMLDOMNode
 Dim xTime  As IXMLDOMNode
 
'Get the attributes of the LoginReq XML message
 Set xSearch  = oXMLDoc.selectSingleNode("//Search")
 Set xTime  = oXMLDoc.selectSingleNode("//Time")
  
 'Assign the values to the local variables
 Search = xSearch.nodeTypedValue
 Time = xTime.nodeTypedValue
   
 'Send parsed XML variables 
  
  Set MyObject = New Google
  MyObject = mGoogle.Main(Search, xTime)
  Set MyObject = Nothing

End Function
[/CODE]

reply - Asked By drammer _ on 07-Mar-06 06:58 PM

MyObject was not declared
Asked By Sushila Patel on 07-Mar-06 08:25 PM
Try writing Private mGoogle As New Google within a sub procedure

Hi! - Asked By drammer _ on 07-Mar-06 11:51 PM

Hi S Patel!

You can't do that, Private is not allowed in procedures. Also, if the entire code posted is within a module then Private mGoogle is visible to all procedures within the module.
Asked By Sushila Patel on 08-Mar-06 07:05 AM
I meant the variable declaration out and the assignment of value within the event
That should work
Thank you all - Asked By Shashi R on 08-Mar-06 09:02 AM
I go it. if i define myobject as new object it works fine.