Private Sub Command1_Click()
  Text2.Text = Left(Text1.Text, 1) & "/" & Mid(Text1.Text, 2, 1) & "/" & Right(Text1.Text, 1)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
 KeyAscii = 0
End If
End Sub

解决方案 »

  1.   

    问题请说得具体一点,上面的肯定有错--只是随便编了一个
    当然用MAskedtbox控件也行,设置它的mask属性
      

  2.   

    222在文本框中显示2/2/2
    那输入2222是表示22/2/2还是表示2/2/22 ?
    用mask控件较好,用text控件,你就得在keypress中控制。
      

  3.   

    把yyyymmdd 格式转换成yyyy/mm/ddPrivate Sub Text1_Validate(Cancel As Boolean)
    Dim xx, yy As String
    If Text1 <> "" Then
       xx = Trim(Text1.Text)
       Text1 = Mid(xx, 1, 4) & "/" & Mid(xx, 5, 2) & "/" & Mid(xx, 7, 2)
       If Not IsDate(Text1) Then
          Cancel = True
          MsgBox "请按 yyyymmdd 格式输入", , "系统信息提示"
          Text1 = ""
        End If
    End If