如果在textbox中输入不为标准格式“19xx-x-x”则返回继续输入怎么实现?才学VB哈 帮帮忙!

解决方案 »

  1.   

    a=split(字符串)
    if ubound(a)=2 then
      if a(0)>1000 and a(0)<3000 then
         if a(1)>=1 and a(1)<=12
            if a(2)>=1 and a(2)<=31
               msgbox "正确",,"aa"
            else
               msgbox "不正确",,"aa"
         else
           msgbox "不正确",,"aa"
         end if
      else
         msgbox "不正确",,"aa"
      end if 
    else
      msgbox "不正确",,"aa"
    end if
    大概意思是这样 还要加上 测试是不是数值 等等
      

  2.   

    isdate函数可以分辨某字符串是否为日期
    用year \month day三个函数可以取出某个日期型函数的年、月、日看下msdn上面的解释吧
      

  3.   

    写错了一点
    a=split(字符串,"-")
    if ubound(a)=2 then
      if a(0)>1000 and a(0)<3000 then
         if a(1)>=1 and a(1)<=12
            if a(2)>=1 and a(2)<=31
               msgbox "正确",,"aa"
            else
               msgbox "不正确",,"aa"
         else
           msgbox "不正确",,"aa"
         end if
      else
         msgbox "不正确",,"aa"
      end if 
    else
      msgbox "不正确",,"aa"
    end if
    大概意思是这样 还要加上 测试是不是数值 等等
      

  4.   

    textbox = Format$(Now, "yyyy-mm-dd") '等于当天日期
    格式化成你的格式textbox=format$(textbox,"yyyy-m-d")
      

  5.   

    Private Sub Command1_Click()
        If Not (IsDate(Text1.Text) And InStr(Text1.Text, "-") = 5 And (InStr(6, Text1.Text, "-") = 7 Or InStr(6, Text1.Text, "-") = 8)) Then
            MsgBox "输入有误!"
            Text1.Text = ""
            Text1.SetFocus
        End If
    End Sub