On Aug 10, 2006, at 8:21 PM, Robert Poland wrote:


Hi,

Using this code in a project with two editfields. Code in editfield1 LostFocus. Run. Enter date (8/8) in editfield1 then tab. The result is the msgbox TWICE and NEVER moving to editfield2. Looks like a BUG to me. Seems to me that the focus should move, with the tab, to the next window before getting the msgbox.

I have worked with this code and found another problem. It seems to try to correct 8/8 to 8/8/06. If I try that again, it gets locked in a perpetual MsgBox loop and requires a Force Quit.

By putting the messages in Timers, the focus will change correctly.

Here is a corrected version. Put this in the LostFocus event of EditField1.

[Sub LostFocus()]

  Dim d As new date
  Dim b As boolean

  b=parsedate(editfield1.text,d)

  // Check parsed date
  If b <> True Then
    Timer1.mode=1 //MsgBox "Invalid Date format!"
  Else
    If d.DayOfWeek <> 7 Then // 7 is Saturday
      Timer2.mode=1 //MsgBox "That is not a Saturday"
      EditField1.text=d.ShortDate
    Else
      // was a Sat., update display to a longdate
      EditField1.text=d.LongDate
    End If
  End If

[End Sub]

In the Timers place the old MsgBox messages. If you want to stay in EditField1 on an Illegal entry, set it's focus in Timer 1.

This is a PRIME example of how Message dialogs inside an Rb event can really mess things up.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to