开发者

Lotus view column compare to string/integer

开发者 https://www.devze.com 2022-12-27 14:24 出处:网络
I have a lotus view that stores a number.I need to perform some math against the开发者_如何学运维 value, but I am having a lot of problems getting the types to match up.

I have a lotus view that stores a number. I need to perform some math against the开发者_如何学运维 value, but I am having a lot of problems getting the types to match up.

doc.numOfGold = numGold 

and CInt(doc.numOfGold) = numGold

and CInt(doc.numOfGold) = CInt(numGold)

and doc.numOfGold = CInt(numGold)

all return type mismatch. I've tried changing the column properties to treat it as a decimal, with no better luck.

Any thoughts?

Thanks!


Never access a field like this: "doc.fieldname". User doc.GetItemValue("fieldname")(0), this returns the correct type.

If doc.numOfGold is a numberfield, and numGold is an int, it should work like this:

Dim numOfGold as integer
numOfGold = doc.GetItemValue("numOfGold")(0)

if doc.numOfGold is a textfield, you have to do a conversion, e.g. val(doc.GetItemValue("numOfGold")(0))

Also verify that your field value is not an empty string, e.g. use a field validation formula.


Never access a field like this: "doc.fieldname".

Bit harsh, accessing a document field value is perfectably acceptable:

x = doc.FieldName(0)

Doc.FieldName = ScalarValue

or even

Doc.FieldName = ArrayOfValues

To be sure of success, you may want to see if 'Doc.HasItem("FieldName")' first (true for getFirstItem too).

NB: GetFirstItem is the direct way to get the field value, for max performance:

x = doc.getFirstItem("FieldName").Values(0)

As this avoids 'default properties'.

Also, the 'assumed default' 'doc.FieldName(0)' can be 'overlooked' by error reporting/syntax checking

0

精彩评论

暂无评论...
验证码 换一张
取 消