vb.netvisual-studio-2010timemaskingmaskedtextbox

VB Masked Textbox Loses Digit


I have a masked textbox in VB.NET to input a time value. I've tried the masks 90:00, 00:00, and ##:##. The first time a value is entered in the box, it inputs fine. I later clear the text with

mskTime.Text = ""

I've also tried

mskTime.Clear()
mskTime.ResetText()

The issue is after the text is cleared and a new time is entered, the first character typed is deleted. More precisely, when I add the time 12:34, I type the 1, it appears in the first character slot. I then press 2, and the 1 disappears and the 2 appears in the second character slot. The character does not disappear when you go to type it again to fix it.

Has anyone seen this issue or know why the first character disappears?


Solution

  • Problem found:

    I had a KeyDown function to handle the user pressing enter in the time field:

        If e.KeyCode = Keys.Enter Then
            Schedule()
            e.SuppressKeyPress = True
        End If
    

    Commenting out

    e.SuppressKeyPress = True 
    

    solves the issue. I originally used that to prevent Windows from making a ding sound each time enter was pressed.