案例陈述 - 空值

时间:2017-03-01 20:37:07

标签: vbscript case isnull

我正在使用Labelview 2015 by Teklynx。它提供了将代码放在Visual Basic Sc​​ripting选项卡中的机会。

我有一些由Case语句驱动的形状和文字颜色。问题是,我需要将颜色默认为“白色”或“清除”,并保持Null值的方式。

以下是摘录:

Dim strShapeName
Dim strName
strShapeName = "ShapeLordosis"
strName = "TextLordosis"

If IsNull(Value) Then
    Document.DocObjects(strShapeName).BackColor = vbWhite
    Document.DocObjects(strShapeName).ForeColor = vbWhite
    Document.DocObjects(strName).BackColor = vbWhite
    Document.DocObjects(strName).ForeColor = vbBlack
Else
    Select Case Value
        'BLACK FONT with BRONZE FILL
        Case 0, 10, 20, 30, 40, 50, 60
            Document.DocObjects(strShapeName).BackColor = RGB(176, 97, 0)
            Document.DocObjects(strShapeName).ForeColor = vbBlack
            Document.DocObjects(strName).BackColor = RGB(176, 97, 0)
            Document.DocObjects(strName).ForeColor = vbBlack
            ...
        'BLACK FONT with SEAFOAM GREEN FILL
        Case 9, 19, 29, 39, 49, 59, 69
            Document.DocObjects(strShapeName).BackColor = RGB(45, 208, 0)
            Document.DocObjects(strShapeName).ForeColor = vbBlack
            Document.DocObjects(strName).BackColor = RGB(45, 208, 0)
            Document.DocObjects(strName).ForeColor = vbBlack
        'BLACK FONT with WHITE FILL
        Case Else
            Document.DocObjects(strShapeName).BackColor = vbWhite
            Document.DocObjects(strShapeName).ForeColor = vbBlack
            Document.DocObjects(strName).BackColor = vbWhite
            Document.DocObjects(strName).ForeColor = vbBlack
    End Select
End If

在我添加If IsNull(Value) Then ...条件之前,代码会运行。当我添加条件时,代码只会给出一个参数不存在的错误。我看到了使用If Else的建议,但我无法让它工作。

有一个执行按钮,当我运行它时,我收到以下错误:

  

Microsoft VBScript运行时错误:类型不匹配:'[string:“”]'at“(null)”

此外,在此选项卡中,还有一个“激活事件呼叫”复选框。然后有3个子类别:

Sub OnChangeFieldData(ByVal Variable, ByRef Value, ByRef Valid)

Sub OnBeforeShowFieldDialog(ByVal Variable, ByVal DialogID, ByVal Options, ByVal Parent, ByRef Result)

Sub OnAfterShowFieldDialog(ByVal Variable... etc)

0 个答案:

没有答案