Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch from LotusScript 1

Status
Not open for further replies.

jurg

MIS
Oct 26, 2001
20
CH
When I do the following, I get an error message „Type mismatch“:

The document contains 3 text fields (fld1, fld2 and fld3). Fld1 contains „AA“, fld2 contains „234“. I would like to combine the content of fields fld1 and fld2 and thus save „AA234“ in fld3. The Notes Debugger shows all 3 fields as variant type (string).

Dim doc as NotesDocument
Dim view as NotesView
....
Var1 = doc.fld1
REM Var1 gets the field value „AA“ (which is what I wanted)
Var2 = doc.fld2
REM Var2 gets the field value „234“ (which is what I wanted)
Var3 = Var1 + Var2 -> Creates a „Type mismatch“ error
Doc.fld3 = doc.fld1 + doc.fld2 also creates a „type mismatch“ error.

What am I doing wrong? (probably needless to mention that I am a beginner with LotusScript...). All help will be much appreciated.

Jurg

 
first of all, all fields are stored internally as an array, even if it's a single value field, which will fit without a problem in a variant variable.

your variant variables contain an array of type string with one element.

(personally I always declare my variables with the corresponding types and set Option Explicit in the options section of the script, which will also help trap typo's in variable names).

what you could do instead is :

Dim doc as NotesDocument
....
Var1 = doc.fld1(0)
REM Var1 gets the field value „AA“ (which is what I wanted)
Var2 = doc.fld2(0)
REM Var2 gets the field value „234“ (which is what I wanted)
Var3 = Var1 + Var2

----

Hope this helps. (I made the same mistake when I first started with LS) Woonjas
IRC: #notes on EFNet
 
Thank you very much for your help. I have already spent so much time on this...

It is working now!

Have a good weekend. Jurg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top