Vb.net 使用vb的NotesDatabase.Search方法中的类型不匹配

Vb.net 使用vb的NotesDatabase.Search方法中的类型不匹配,vb.net,lotus-notes,Vb.net,Lotus Notes,我需要搜索一个notes数据库与一组给定的条件使用VB。我在 并根据第3个示例得出以下代码: Dim notesSession As Object = CreateObject("lotus.NotesSession") notesSession.Initialize(Password) Dim notesDatabase As Object = notesSession.GETDATABASE(ServerName, DatabaseName) Dim Quer

我需要搜索一个notes数据库与一组给定的条件使用VB。我在
并根据第3个示例得出以下代码:

    Dim notesSession As Object = CreateObject("lotus.NotesSession")
    notesSession.Initialize(Password)
    Dim notesDatabase As Object = notesSession.GETDATABASE(ServerName, DatabaseName)
    Dim Query as String = "{Form = Project}"
    Dim notesDocumentCollection As Object = notesDatabase.Search(Query, Nothing, 0)
    Dim notesDocument As Object = notesDocumentCollection.GetFirstDocument
但是在notesDatabase.Search(Query,Nothing,0)中,它给了我一个运行时异常,表示类型不匹配。对于第二个和第三个参数,可以不使用任何内容和0

因此,我怀疑我的第一个论点有问题

notesDocumentCollection=notesDatabase.Search(公式$, notesDateTime,maxDocs%)


谁能告诉我我做错了什么吗?

你的公式错了。这是必须的

"Form = ""Project"""
此外,COM类和vb.net之间的“Nothing”概念似乎有所不同,这是您在尝试时发现的:您需要使用正确类型的参数。就你而言:

New Runtime.InteropServices.UnknownWrapper(Nothing)
而不是简单地

Nothing

作为第二个参数

你的公式错了。它需要是“Form=”“Project”“”。此外:我从未见过代码,其中Dim和赋值在同一行中。。。我不知道,这是vb.netThanks中的有效代码,更改公式有效。但必须将参数2从Nothing更改为New Runtime.InteropServices.UnknownRapper(Nothing)以避免异常。是的,它是有效的,在vb中工作:)您应该添加上述注释作为答案。