简体   繁体   English

子程序“测试”中的语法错误

[英]Syntax error in subroutine 'Test'

I have the following sub function in VBA: 我在VBA中具有以下子功能:

Sub test()
    index_match_array(Range("D5").Value,Range("BZ:BZ").DataSeries,"Hardware",1,2)
End Sub

This calls the function which starts: 这将调用以下函数:

Option Explicit
Function index_match_array(loookup As String, table_array As Range, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String()

Dim lookup_array() As String
Dim result_array() As String
...
...
index_match_array = result_array

End Function

When I compile I get the error message: 编译时收到错误消息:

Compile error: Syntax error 编译错误:语法错误

I suspect it's to do with the second parameter, the range one, but I'm not sure? 我怀疑这与第二个参数(范围一)有关,但是我不确定吗?

' Data Series return type is Variant , Change the table_array to Variant ' Function is in Array, change Function index_match_array to String 'Data Series返回类型为Variant,将table_array更改为Variant'函数在Array中,将Function index_match_array更改为String

Option Explicit
Sub test()

    Dim sString(10) As String
    sString(1) = index_match_array(Range("D5").Value, Range("BZ:BZ").DataSeries, "Hardware", 1, 2)

End Sub


Function index_match_array(loookup As String, table_array As Variant, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String

Dim lookup_array(10) As String
Dim result_array(10) As String

result_array(1) = "Test Value"

index_match_array = result_array(1)

End Function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM