2012-11-26 18 views
6

Dışarıdan çıkar bildirimini kaldırdığımda, addmessage tıklandığında txtBillTxtSetSrc alanına atlayacak bir bağlantı oluşturur. If ifadesinin içinde bağlantıÇalışma zamanı hatası: Bir if ifadesinin içinde çalışmayan nesne bekleniyor

If if ifadesi olmadan çalışır. Neden bununla çalışmıyor?

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 

cevap

1

onay emin txtBillTxtSetSrc kullanım sırasında geçerli olduğundan emin olmak için. Eğer Nothing (null) değilse, .Text özelliğine vb. Erişemezsiniz. Ayrıca eğer bir şey ise özelliklerden biri olabilir. Onları tek tek kontrol ederim.

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 
İlgili konular