[374.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) <> 4 Then MsgBox ("4桁の数字を入力して下さい") Exit Sub End If 'hh:mm形式の文字列にする strRemake = Left(strInput, 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