在vb6中将焦点设置在txtbox中?

时间:2015-12-14 16:56:41

标签: date textbox vb6 controls setfocus

我正在使用此代码验证日期的msktxtbox。一切正常,但真正令我烦恼的是,在msgbox弹出并且用户点击确定后,焦点不会转到mskDOB。它转到下一个“TAB INDEX”控件。它是做什么的?我如何解决它?

Dim datCurrentDate As Date
datCurrentDate = Format(Now, "MM/DD/YYYY")
If Not (IsDate(mskDOB.Text)) Then
    MsgBox "Please check the Date, and re-enter again", vbInformation, "Error"
    mskDOB.SetFocus
    Exit Sub
    Else
        If Format(CDate(mskDOB.Text), "MM/DD/YYYY") >= datCurrentDate Then
            MsgBox "Please check the Date, and re-enter again", vbInformation, "Error"
            mskDOB.SetFocus
            Exit Sub
        End If
End If

1 个答案:

答案 0 :(得分:1)

而不是使用mskDOB.SetFocus尝试使用cancel = true

  

我尝试将此作为评论发布,但我没有足够的声誉发表评论,因此我将此作为答案发布