0

I have tried every help available on all other relative topics, but nothing sorted out the issue , Code is as below

VB6 (DLL Code):

Public Function enterorder(vals() As Variant, ordhdr() As Variant) As String
................... code ............
enterorder = "done"
End Function

ASP :

SET objdll = server.createobject("dllproname.classname")

Dim values(1, 4)
Dim ordhdr(1)
dim ret
ordhdr(0) = "1012"
ordhdr(1) = "ASP TESTING descript"
values(0, 0) = "testing "
values(0, 1) = "testing 2"
values(0, 2) = "HO"
values(0, 3) = "2.0000"
values(0, 4) = "12.0000"

values(1, 0) = "testing part 2 "
values(1, 1) = "testing again"
values(1, 2) = "HO"
values(1, 3) = "2.0000"
values(1, 4) = "12.0000"

ret = objdll.EnterOrder(values(), ordhdr())
response.write("Done")

The code is giving error :

Microsoft VBScript runtime error '800a0009' Subscript out of range

I have tried removing the multidimensional arrays and only sending normal array, same error remains.

I have also tried removing paranthesis () while passing the array like ( objdll.EnterOrder(values , ordhdr)

) it gives Type Mismatch error.

My VB6 code was accepting string arrays, but i changed it to variant type following some guidelines on help topics, that also didn't helped.

The same code works , if i add this dll into vb6 project reference and then call the same function, it works perfect. But same code with asp don't work.

Thanks.

King Khan
  • 49
  • 1
  • 11

2 Answers2

0

remove the () when declaring as variant

Public Function enterorder(vals As Variant, ordhdr As Variant) As String
Hrqls
  • 2,944
  • 4
  • 34
  • 54
0

ok guys, thanks for the help, but i got it sorted out. I did some research and got the answer that while passing parameters from asp to dll(made by vb6) the only data type that works is "Variant". Secondly passing arrays to dll is quite difficult(i won't say it's impossible, i read it somewhere that it's not allowed to pass arrays from asp to vb6 dll). so i made string with the values and did a split in the vb6 code so i get the array after splitting.

For Example ASP Code:

dim values
values = "a,b,c,d,e|f,g,h,i,j" 
strlen = "1,4"
ret = objdll.EnterOrder((values), (dsordhdr),(strlen))

The Main thing was while passing the parameters i put wraped the variables with paranthesis , as it didn't worked without it, wrapping it with parameters make it like an expression so it worked.

VB6 Code

Public Function enterorder(ByVal valstring As Variant, ByVal ordhdrstring As Variant,     ByVal arrlenstr As Variant) As Variant
    Dim vals() as string
    Dim arrlen() As String
    arrlen = Split(arrlenstr, ",")
    ReDim vals(arrlen(0), arrlen(1)) As String
    valarry = Split(valstring, "|")
    For ind = 0 To UBound(valarry)
        orval = Split(valarry(ind), ",")
        For sind = 0 To UBound(orval)
            vals(ind, sind) = orval(sind)
            outstr = outstr & orval(sind) & ","
        Next

    Next

so it worked like that. Redim was necessary as first time i declared array and while doing redim i put the indexes of the array. didn't worked without it.

King Khan
  • 49
  • 1
  • 11