Hi,
This seems to be a weird bug.
The code is at the end. Past it to an agent or so, and try to compile it.
What happens is a “type mismatch on doc2” error in compilation. The real “nice” part is if you change the order of the notesdocument declarations (to doc1, doc2), it will work perfectly. It also works if you declare them seperatly (or even if you just change “Notesdocument” to “Variant” ).
Am I missing something or is there somekind of a bug ?
Sub Test
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc2, doc1 As notesdocument
Set db = session.CurrentDatabase
Set doc1=db.CreateDocument
doc1.dummy = "aaa"
Call doc1.Save(True,True)
Set doc2=db.CreateDocument
doc2.dummy = "bbb"
Call doc2.Save(True,True)
Call doc1.MakeResponse(doc2)
Call doc1.save(true,true)
End Sub
Subject: Change the dim statement…
Dim doc2 as notesdocument, doc1 as notesdocument.This will solve the problem.
Subject: RE: Change the dim statement…
Hi,thanks for your input. But I ask again, is there a bug ??
As i wrote previously … “It also works if you declare them seperatly”.
It does not stand a problem to me overcoming this compiling error, what i meant is that there might be a bug since all you need, for instance, is to change the order of the declaration.
Subject: RE: Change the dim statement…
It’s not a compilation error. In the statement:
Dim doc1,doc2 As NotesDocument
you are saying
“Set aside some room for an unspecified variable called doc1, – oh, and I’d also like you to reserve a room for an object variable called doc2, which will be a NotesDocument. If you don’t mind.”
You have never told the compiler what datatype doc1 is. Untyped variables are variants, not NotesDocuments, and may or may not have the properties and methods you need them to have. If you don’t want to declare them on separate lines, you have to use this syntax:
Dim doc1 As NotesDocument,doc2 As NotesDocument
Subject: RE: Change the dim statement…
you are absolutly right!
Visual Basic 6 does the same thing (.NET doesn’t do it anymore - you can declare multiple variables in one line of the same datatype).
Let’s just say it’s a compiler “feature”. :-))