6

当我删除外部 if 语句时,addmessage将创建一个链接,单击该链接将跳转到该txtBillTxtSetSrc字段。在 if 语句中,链接显示

Microsoft JScript 运行时错误:预期对象”。

它可以在没有 if 语句的情况下工作。为什么它不能与它一起工作?

If Me.txtBillTxtSetSrc.Text.Trim.Length > 0 Then
  validateExpression = "^[BCGHJSR][0-9][0-9]"
  ismatch = Regex.IsMatch((txtBillTxtSetSrc.Text).ToUpper, validateExpression)

  If ismatch = False Then
    tempErrorMsg = LASPBS_Classes.Errors.MainframeError.getError("281W") ' Text Set Must be B01-B99, etc.
    Me.MessageCenter.addMessage(tempErrorMsg, "#", "txtBillTxtSetSrc", "form1", "E")
    Me.MessageCenter.Visible = True
  End If
End If
4

1 回答 1

1

检查以确保 txtBillTxtSetSrc 在使用时有效。如果它是 Nothing(null) 那么你不能访问 .Text 属性等等。此外,如果它是某种东西,它可能是属性之一。我会检查他们一个。

 If Not (Me.txtBillTxtSetSrc is Nothing) andalso (Me.txtBillTxtSetSrc.Text.Trim.Length > 0) Then 
    validateExpression = "^[BCGHJSR][0-9][0-9]"
    ismatch = Regex.IsMatch((txtBillTxtSetSrc.Text).ToUpper, validateExpression)

    If ismatch = False Then
      tempErrorMsg = LASPBS_Classes.Errors.MainframeError.getError("281W") ' Text Set Must be B01-B99, etc.
      Me.MessageCenter.addMessage(tempErrorMsg, "#", "txtBillTxtSetSrc", "form1", "E")
      Me.MessageCenter.Visible = True
  End If
 End If
于 2013-07-29T18:54:59.117 回答