[373.xls] ' [mjSumple] のコード '■■ 入力補正機能付き日付入力 ■■ ' ' Dim strInput As String Dim strRemake As String 'フォームを表示します Sub frmSumple_Show() 'フォームの表示 frmSumple.Show End Sub Sub Btn1_Click() strInput = frmSumple.txtInput0.Text '値が入力されているかチェック If Len(strInput) <> 8 Then MsgBox ("8桁の数字を入力して下さい") Exit Sub End If 'yyyy/mm/dd形式の文字列にする strRemake = Left(strInput, 4) & "/" & Mid(strInput, 5, 2) & "/" & Right(strInput, 2) '入力値から年月日を取り出します If IsDate(strRemake) Then frmSumple.txtInput0.Text = strRemake Else MsgBox ("日付に変換できません") End If End Sub ' [frmSumple] のコード Private Sub txtInput0_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyReturn Then Call Btn1_Click End If End Sub