textbox validating

  • Thread starter Thread starter Darin
  • Start date Start date
D

Darin

I have a textbox that I have a sub that handles textbox_validating. That
sub says:

Private Sub tItem_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles tItem.Validating
If Not e.Cancel Then
If Not IsBlank(tItem.Text) Then
If LoadItem() Then
e.Cancel = False
Else
e.Cancel = True
End If
End If
End If
End Sub

My problem is the function LoadItem wants to display a message (in this
case something like make sure you sell this item with an antenna or
something like that). But, it seems to get hung in a loop and won't
display the message until I ctrl-alt-break.

So how can I have a textbox that when the user gets off that box (by tab
or clicking somewhere else), display a messagebox? I think I am missing
something simple.

Thanks.
Darin

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
ditto w/ the error provider and runs fine on mine too...however, you may
want to simplify your code...

from this:

If Not e.Cancel Then
| If Not IsBlank(tItem.Text) Then
| If LoadItem() Then
| e.Cancel = False
| Else
| e.Cancel = True
| End If
| End If
| End If
| End Sub


to this:

if e.cancel orelse isblank(titem.text) then return
e.cancel = loaditem()

just in case you (or your co-workers) are anal about code maintenance.

but that's just my $0.02 usd. ;^)
 
Back
Top