( 13 ) 对窗体 test 上文本框控件 txtAge 中输入的学生年龄数据进行验证 。 要求 : 该文本框中只接受大于等于 15 且小于等于 3 。的数值数据,若输入超出范围则给出提示信息。该文本控件的 BeforeUpdate 事件过程代码如下,请在空白处填入适当的语句,使程序可以完成指定的功能。Private Sub txtAge_ BeforeUpdate ( Cancel As Integer )If Me!txtAge= “” Or 【 14 】( Me!txtAge ) Then’ 数据

题目

( 13 ) 对窗体 test 上文本框控件 txtAge 中输入的学生年龄数据进行验证 。 要求 : 该文本框中只接受大于等于 15 且小于等于 3 。的数值数据,若输入超出范围则给出提示信息。该文本控件的 BeforeUpdate 事件过程代码如下,请在空白处填入适当的语句,使程序可以完成指定的功能。

Private Sub txtAge_ BeforeUpdate ( Cancel As Integer )

If Me!txtAge= “” Or 【 14 】( Me!txtAge ) Then

’ 数据为空时的验证

MsgBox “ 年龄不能为空! ” , vbCritical , “ 警告 ”

Cancel=True ’ 取消 BeforeUpdate 事件

ElseIf IsNumeric ( Me!txtAge ) =False Then

’ 非数值数据输入的验证

MsgBox “ 年龄必须输入数值数据! ” vbCritical, “ 警告 ”

Cancel=True ‘ 取消 BeforeUpdate 事件

ElseIf Me!txtAge<15 Or Me!txtAge 【 15 】 Then

’ 非法范围数据输入的验证

MsgBox “ 年龄为 15 一 30 范围数据! ” , vbCritical, “ 警告 ”

Cancel= True ’ 取消 BeforeUpdate 事件

Else ’ 数据验证通过

MsgBox “ 数据验证 .K! ” , vbInformation, “ 通告 ”

End If

End Sub


相似考题
更多“( 13 ) 对窗体 test 上文本框控件 txtAge 中输入的学生年龄数据进行验证 。 要求 : 该文本框中只 ”相关问题
  • 第1题:

    窗体中有一个年龄文本框 txtAge,下面 代码可以获得文本框中的年龄值。

    A.int age = txtAge;

    B.int age = txtAge.Text;

    C.int age = Convert.ToInt32(txtAge);

    D.int age = int.Parse(txtAge.Text);


    int age = int.Parse(txtAge.Text);

  • 第2题:

    9、可以在窗体中进行数据输入的控件是()。

    A.标签控件

    B.文本框控件

    C.命令按钮控件

    D.图像控件


    文本框控件

  • 第3题:

    35、在窗体中,若想利用文本框控件来输入操作密码,则必须对其()属性进行设置。

    A.名称

    B.控件来源

    C.输入掩码

    D.默认值


  • 第4题:

    11、要验证文本框中输入的数据是否为合法的邮编,需要使用()验证控件。

    A.RequiredFieldValidator

    B.RangeValidator

    C.CompareValidator

    D.RegularExpressionValidator


    RequiredFieldValidator 控件

  • 第5题:

    判断用户通过输入界面中的文本框控件输入的信息是否是偶数,要求用验证控件实现,我们需要选择哪种验证控件()?

    A.RequiredFieldValidator

    B.RangeValidator

    C.CompareValidator

    D.CustomerValidator


    CustomerValidator