6

When I remove the outside if statement, addmessage will create a link that will jump to the txtBillTxtSetSrc field when clicked. Inside of the if statement the link displays

Microsoft JScript runtime error: Object expected".

It works without the if statement. Why does it not work with it?

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

1 Answer 1

1

check to make sure txtBillTxtSetSrc is valid at the time of usage. If it is Nothing(null) then you cant access the .Text property and so on. Also if it is something it could be one of the properties. I would check them on by one.

 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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.