Runtime error: an object that does not work inside the if statement

When I delete the external if statement, addmessage will create a link that will go to the txtBillTxtSetSrc field when clicked. A message is displayed inside the if statement

Microsoft JScript runtime error: expected object.

It works without an if statement. Why doesn't he work with him?

 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 
+6
source share
1 answer

to make sure txtBillTxtSetSrc is valid during use. If it is Nothing (null), you cannot access the .Text property and so on. Also, if this is something, this may be one of the properties. I would check them out alone.

  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 
+1
source

All Articles