Lotus Designer软件,命令和Lotus Script

时间:2011-10-20 09:25:43

标签: lotus-notes

我最近从互联网上尝试过这个莲花脚本,添加字段并获取输入。

Sub Click(Source As Button)
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim celsius As String
    Set uidoc = workspace.CurrentDocument
    x = uidoc.FieldGetText( "Field_F" )
    celsius = (x-32)*(5/9)
    Call uidoc.FieldSetText("Field_C", celcius) 
End Sub

当我执行时,我得到类型错误匹配错误,因为我给出的输入是数字,而变量摄氏数被声明为字符串。

任何人都可以说出错了什么.. 我知道它显而易见但仍然无法找到,因为我是莲花笔记的新手。

3 个答案:

答案 0 :(得分:3)

您正在混合字符串和数字。确保计算的输入是数字。

   Sub Click(Source As Button) 
    Dim workspace As New NotesUIWorkspace 

    Dim uidoc As NotesUIDocument 
    Set uidoc = workspace.CurrentDocument 

    Dim celsiusString As String 
    celsiusString = uidoc.FieldGetText( "Field_F" ) 

    Dim y As Double 
    y = Val(x) 

    Dim celsiusvalue As Double 
    celsiusvalue = (y-32)*(5/9) 

    celsiusString = Str$(celciusvalue) 
    Call uidoc.FieldSetText("Field_C", celsiusString) 
End Sub 

答案 1 :(得分:0)

你的变量拼写不一致,

Dim celsius As String Dim celsiusvalue As Double

celsius = Str $(celciusvalue) 调用uidoc.FieldSetText(“Field_C”,celcius)

注意摄氏/细胞的拼写。

在选项中使用Option Declare来避免这种情况,它会将未命中拼写作为未声明的变量捕获。

答案 2 :(得分:0)

Sub Click(Source As Button)

    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim celsius, x As Double
    Set uidoc = workspace.CurrentDocument
    x = Cdbl(uidoc.FieldGetText( "Field_F" ))
    celsius = Cdbl((x-32)*(5/9))
    Call uidoc.FieldSetText("Field_C", Cstr(celcius)) 

End Sub