当我删除外部 if 语句时,addmessage
将创建一个链接,该链接将跳转到 txtBillTxtSetSrc
单击时的字段。在 if 语句中,链接显示
Microsoft JScript runtime error: Object expected".
它在没有 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
最佳答案
检查以确保 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
关于vb.net - 运行时错误 : Object expected not working inside of an if statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13568447/