使用.Contains时出现错误424

时间:2014-07-03 10:28:55

标签: vba ms-access access-vba

当我在VB中使用.Contains时,我有一个错误424“需要对象”。

请参阅以下代码:

Set oRst = oDB.OpenRecordset("Check Task Aircraft Listing", dbOpenDynaset)

Do While oRst.EOF = False
  Dim revNumber As String
  revNumber = oRst.Fields("CTAL_Rev")
  Dim aircraft As String
  aircraft = Me.aircraf
  Dim truc As Boolean
  truc = Revnumber.Contains(aircraft) <= error
  If truc = True Then
  ...

有人知道什么是错的吗?

1 个答案:

答案 0 :(得分:1)

String.Contains是VBA不支持的VB.NET构造。 (VBA 比VB.NET旧。)VBA等价物将是

truc = (InStr(revNumber, aircraft) > 0)