找回密码
 加入
搜索
查看: 1592|回复: 5

[AU3基础] [已解决] 新人求助数组和数组搜索问题

  [复制链接]
发表于 2017-6-21 08:31:23 | 显示全部楼层 |阅读模式
本帖最后由 liuzhexin 于 2017-6-21 14:32 编辑

代码如下:

For $i=1 To UBound($aResult, $UBOUND_ROWS)
$a = String ($aResult[$i][2])

        If $index = _ArraySearch($aResult1, $a, 0, 0, 0, 0, 1, 2) Then
                MsgBox(0,"",$index)
        EndIf

Next
$aResult和$aResult1是从excel分别读取过来的二个sheet,想在result1的第二列中搜索result里面第二列的内容。

但是每次运行的时候都报错如下:

"C:\Work\Automation\au3\Validation\DFM\DFM.au3" (31) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$a = String ($aResult[$i][2])
$a = String (^ ERROR

问题:当我把if的那个判断注释掉的时候,这行代码是可以执行过去的。但是只要if开始运行,就会报这个错误。。。。
发表于 2017-6-21 09:09:38 | 显示全部楼层
查看下返回值
 楼主| 发表于 2017-6-21 11:02:49 | 显示全部楼层
回复 2# lxwlxwayy

多谢啦,我刚才修改了一下。

_ArraySearch($aResult1, "241000-05", 0, 0, 0, 0, 1, 2)

直接用这个array search写死查找的内容,但是返回值是@error=6,是没有找到。
但是数组的第二列里面确实有这个值啊,我看了一下帮助,这个函数是不是还有什么隐藏的限制?
发表于 2017-6-21 12:02:10 | 显示全部楼层
已经提醒下标溢出了, 明显是 For $i=1 To UBound($aResult, $UBOUND_ROWS) 这句的问题.
却非找其它代码的事....
 楼主| 发表于 2017-6-21 12:44:28 | 显示全部楼层
回复 4# Alam


  多谢了,明白了~~~~以后加强一下基础知识。。。。
发表于 2017-6-21 13:17:28 | 显示全部楼层
基础知识需要认真看哇··
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-25 16:50 , Processed in 0.071824 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表