hcl-bot
December 14, 2005, 3:17pm
1
Hi,
A multi value field named as “existing_values” contains values like “A12 011|Super Section”, “B12 011|Middle Section”, etc…
I want to get “A12” and “B12” values into StrVal (code below) from “existing_values” field values
When I observed in log it was giving an error message that “Goto error Illegal function call on line …”
Dim vVar As Variant
Dim StrVal As String
Dim lCounter As Long
vVar = DocMain.GetItemValue(“existing_values”)
For lCounter = Lbound(vVar) To Ubound(vVar)
'** To get output like “A12”, “B12”
StrVal = Trim(Left(Trim(vVar(lCounter)),Instr(1,Trim$(vVar(lCounter)),“|”) - 1)) 'Goto error Illegal function call on line"
Pls suggest me, how to prevent this.
Regards
Raj
hcl-bot
December 15, 2005, 9:56am
2
Subject: Illegal function call
I would use the new strToken function in R6. It’s faster, easier and safer. Your code would look something like this:
Dim vntVal As Variant
Dim strLeftPart As String
Dim strFinal As String
Dim k As Integer
vntVal = DocMain.Existing_Values
For k = 0 To Ubound (vntVal)
strLeftPart = Strtoken(vntVal(k),"|")
strFinal = Strtoken(strLeftPart," ")
Next
hcl-bot
December 15, 2005, 10:27am
3
Subject: RE: Illegal function call
Minor correction - I forgot to add the ‘Word Number’ parameter:
Dim vntVal As Variant
Dim strLeftPart As String
Dim strFinal As String
Dim k As Integer
vntVal = DocMain.Existing_Values
For k = 0 To Ubound (vntVal)
strLeftPart = Strtoken(vntVal(k),“|”,1)
strFinal = Strtoken(strLeftPart," ",1)
Next
hcl-bot
December 16, 2005, 9:44am
4
Subject: Illegal function call
You are getting off to a bad start by not using the class that Lotusscript provides for dealing with item values - notesitem.
You could also use Evaluate to extract the string you want. I always find that more intuitive than Instr.
Try something like this
dim v as variant
dim strval As String
dim item as notesitem
dim i as integer
set item = DocMain.GetfirstItem(“existing_values”)
for i = 0 to ubound(item.values)
v = evaluate(“@LeftBack (”“”+ item.values(i)+“”" ; “”|“” )")
strval = v(0)
next i
Of course Evaluate might insist on treating the pipe as a quote, in which case use Instr.
hcl-bot
December 14, 2005, 4:05pm
5
Subject: Illegal function call
Convert all to strings as follows and check if you get the same error?
Dim ICounter as integer (why using long here?)
dim pos as integer
dim tmp as string
tmp = trim$(vVar(lCounter))
pos = Instr(1, tmp,“|”)
StrVal = Trim$(Left$(tmp, pos - 1))
If there is still a problem, you can debug it and check the variable values. Hope this helps
hcl-bot
December 14, 2005, 5:00pm
6
Subject: RE: Illegal function call
Hi,
thanks for response … Still same error message at
StrVal = Trim$(Left$(tmp, pos - 1))
pls advise
Raj
hcl-bot
December 14, 2005, 5:21pm
7
Subject: RE: Illegal function call
Change the name of the variable to
tmpVal
instead of strVal
This should work
hcl-bot
December 14, 2005, 5:30pm
8
Subject: RE: Illegal function call
Changed… but not works.
Whats difference between strVal to tmpVal