下面的格式校验是:错的,我应怎样格式校验呢?  
Private Function Get_the_timespan() As Double
        Dim d_timespan As Double
        '格式校验        '获取timespan
        If TB_date.Text <= 24 Then
            d_timespan = CDbl(TB_date.Text) / 24
            TB_result.Visible = False        Else            TB_result.Visible = True
            TB_result.Text = "时间范围不对!"
        End If        'If IsNumeric(TB_date.Text) Then
        '    d_timespan = CDbl(TB_date.Text) / 24
        '    TB_result.Visible = False        'Else        '    TB_result.Visible = True
        '    TB_result.Text = "格式不对!"
        'End If
        Return d_timespan
    End Function

解决方案 »

  1.   

    什么是24小时内查询???
    try
    {
    Date.Parse(textbox1.text);
    }
    catch
    {
    }
      

  2.   

    前台js校验可以吗?
    <script language="javascript">

    function Form1_Validator(theForm)
    {
     if (theForm.time.value == "")
      {
        alert("时间不能为空!");
        theForm.time.focus();
        return (false);
      } reg=/^\d{2}$/;
       if(!reg.test(theForm.time.value))
    {
    alert("请输入正确的时间形式,请输入两位的数字!");
    theForm.time.focus();
    return(false);
    }   
     if(theForm.time.value<0 || theForm.time.value>24)
      {
        alert("请输入正确的时间形式,您填的时间不能小于0或大于24!");
        theForm.time.focus();
        return (false);
      }
     }
    </script>后台:按钮假设为time
    time.Attributes.Add("onclick", "return Form1_Validator(this.form);");