首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Condition1或Condition2

Condition1或Condition2
EN

Stack Overflow用户
提问于 2013-10-25 10:48:18
回答 2查看 492关注 0票数 2

我想做这样的事:

代码语言:javascript
复制
strCurrentName = rstAux.Fields("Name")
strCurrentMat = rstAux.Fields("ID")

    Dim rstAux                      As Recordset
    Dim rstReal                     As Recordset
    Dim strCurrentName              As String
    Dim strCurrentMat               As String

    Set rstAux = New ADODB.Recordset
    Set rstReal = New ADODB.Recordset

    If( (strCurrentName = rstReal.Fields("Name")) OR (strCurrentMat = rstReal.Fields("ID")) Then  
            'codeee
    End If

在VB6上有可能吗?

我尝试了不同的方法来做到这一点,但是我总是会遇到这样的错误:

变量使用Visual 中不支持的自动化类型

好的,我明白这句话的意思,但我想知道是否有办法做到这一点。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-25 11:12:50

好的,您所有的变量都是字符串,请检查‘`rstReal.(“字段”)的返回是否也是字符串,如果不是,则进行转换。我相信名字是字符串,所以检查"ID“。

代码语言:javascript
复制
If(strCurrentName = rstReal.Fields("Name") OR (strCurrentMat = CString(rst.Fields("ID")) Then
     'code code
End If
票数 2
EN

Stack Overflow用户

发布于 2013-10-25 11:15:04

这应该是可行的:

代码语言:javascript
复制
Dim rstAux                      As New ADODB.Recordset
Dim rstReal                     As New ADODB.Recordset
Dim strCurrentName              As String
Dim strCurrentMat               As String

If strCurrentName = rstReal.Fields("Name").Value Or _
   strCurrentMat = rstReal.Fields("ID").Value Then
    'codeee
End If

但是由于.ValueField对象的默认属性,所以它也应该与您的版本一起工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19587746

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档