yyyy/mm/ddといった日付の入力チェックに利用
Public Class Form1
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If ActiveControl.CausesValidation = False Then
Exit Sub
End If
If Not IsDate(TextBox1.Text) Then
MsgBox("日付を 2005/05/22 のような形式で入力してください。", MsgBoxStyle.Information)
e.Cancel = True
End If
End Sub
Private Sub TextBox1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Validated
If ActiveControl.CausesValidation = False Then
Exit Sub
End If
TextBox1.Text = CDate(TextBox1.Text).ToString("yyyy/MM/dd")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class
http://homepage1.nifty.com/rucio/main/dotnet/shokyu/standard23.htm
0 件のコメント:
コメントを投稿