Hi all,I am passing a variant array to a function in LS.When going through the debugger,the I am getting an error.Below is my code:
Function updSecurity (typeDef As Variant,defdForEmpNbr As Variant,rdrsEmpNbr As Variant,authrsEmpNbr As Variant)
Dim keyRdrs() As String
Dim keyAuthrs() As String
Redim keyRdrs(Ubound(rdrsEmpNbr)) As String
Redim keyAuthrs(Ubound(authrsEmpNbr)) As String
keyAuthrs(0) = “L0=” & Cstr(authrsEmpNbr(0)) & “/L1=frmEmpPrf”
The value of authrsEmpNbr(0) exists when going thru the debugger.But when evaluating in the expression above it says Type Mismatch.I would appreciate if someone could help me here.
Thanks,
Sreeni.
Subject: Arrays Issue
Haven’t tested this but I suspect it’s the ‘(0)’ in the keyAuthrs(0)=‘…’. Try doing keyAuthrs = ‘…’
or
Dim keyAuthrs(0) as string
Ernest
Subject: Arrays Issue
Don’t you have to specify the return type of the Function?
Ex:
“Public Function GetLockDoc(strDocID) As notesDocument”
Subject: Arrays Issue
It seems I just had the same error. I’m not sure if the problem is what I’m about to state as it doesn’t make much sense to me.
I know Ubound returns an integer, but try someint% = Ubound(rdrsEmpNbr)
redim keyRdrs(someint%) as string
Just a shot and I know it doesn’t make any sense.
Subject: Arrays Issue
Thanks for the reply…This is part of an agent and when I try to use a Print statement as:Print authrsEmpNbr(0) it still fails here.
Thanks again,
Sreeni.
Subject: Arrays Issue
What are you trying to do with this function (In plain english)?
Subject: Arrays Issue
I am not able to reproduce your error.
What I do not understand is that you have a “Type Mismatch” error on this line. How can the function Cstr cause a Type Mismatch error in this case? I would expect a “Subscript out of Range”.
I use the code below which works
Sub main
Dim typeDef As Variant
Dim defdForEmpNbr As Variant
Dim rdrsEmpNbr As Variant
Dim authrsEmpNbr As Variant
typeDef = "Test"
defdForEmpNbr = "Test"
Redim rdrsEmpNbr(2) As Variant
rdrsEmpNbr(0) = "rdrsEmpNbr 0"
rdrsEmpNbr(1) = "rdrsEmpNbr 1"
rdrsEmpNbr(2) = "rdrsEmpNbr 2"
Redim authrsEmpNbr(2) As Variant
authrsEmpNbr(0) = "authrsEmpNbr 0"
authrsEmpNbr(1) = "authrsEmpNbr 1"
authrsEmpNbr(2) = "authrsEmpNbr 2"
Call updSecurity(typeDef, defdForEmpNbr ,rdrsEmpNbr, authrsEmpNbr)
End Sub
Function updSecurity (typeDef As Variant,defdForEmpNbr As Variant,rdrsEmpNbr As Variant,authrsEmpNbr As Variant)
Dim keyRdrs() As String
Dim keyAuthrs() As String
Redim keyRdrs(Ubound(rdrsEmpNbr)) As String
Redim keyAuthrs(Ubound(authrsEmpNbr)) As String
keyAuthrs(0) = "L0=" & Cstr(authrsEmpNbr(0)) & "/L1=frmEmpPrf"
Msgbox keyAuthrs(0)
End Function