If I run the following code, as is, I get a Type MisMatch error when it hits the line assigning “Office”.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim text As String
Dim temp(0) As String
'Dim array1(2) As String
'Dim array2(2) As String
'Dim array3(2) As String
'Dim ret As Variant
Dim Office As Variant
Set db = session.CurrentDatabase
OfficeNams = Evaluate({@Sort(@Unique (@DbColumn("":"NoCache";"";"Examiner Count";2)))})
OfficeNums = Evaluate({@Sort(@Unique (@left(@DbColumn("":"NoCache";"";"Examiner Count";2);2)))})
Open "c:\file.txt" For Input As #1
Do While Not Eof(1)
Line Input #1, text
temp(0) = Left(text,2)
'ret = Replace(array1, array2, array3)
Office = Replace(temp, OfficeNums, OfficeNams)
.
.
.
However if I remove the Rems from the 4 dim statements and the “ret” Replace statement, then the Office replace works.
…help…
Subject: Replace function - what am I doing wrong?
Turn on debugger and when you hit the error look at temp, OfficeNums and OfficeNams and make sure they have the values you expect.
Subject: Replace function - what am I doing wrong?
Hello Ron,
If you don’t Dim your arrays, and if they have only one element, they will be considered as string and not arrays as string. this what is causing the bug.
Best regards,
Fadi Kiwan
Subject: RE: Replace function - what am I doing wrong?
There are multiple elements, so that is not what is causing the problem.
When I take off the rem on the first replace (which has no data in any of the arrays) then the second replace works, even thought they share no data what so ever.
Subject: RE: Replace function - what am I doing wrong?
What error do you see when you step thru the agent with the debugger on?
Subject: RE: Replace function - what am I doing wrong?
I get a Type MisMatch error when it hits the line assigning “Office”. However if I remove the Rems from the 4 dim statements and the “ret” Replace statement, then the “Office” replace works.