Thema Datum  Von Nutzer Rating
Antwort
02.02.2017 19:33:50 BlackJack66
NotSolved
02.02.2017 19:55:51 Crazy Tom
NotSolved
03.02.2017 08:16:30 BlackJack66
NotSolved
03.02.2017 07:08:40 GraFri
NotSolved
03.02.2017 08:26:41 BlackJack66
NotSolved
03.02.2017 10:58:32 Gast70117
NotSolved
03.02.2017 13:40:21 BlackJack66
NotSolved
Blau Datum in InputBox
03.02.2017 15:50:24 SJ
NotSolved
03.02.2017 17:21:27 Gast10567
NotSolved
04.02.2017 12:33:51 SJ
NotSolved
04.02.2017 09:02:31 Gast70117
NotSolved
04.02.2017 20:30:12 GraGri
Solved
14.02.2017 08:06:07 BlackJack66
NotSolved

Ansicht des Beitrags:
Von:
SJ
Datum:
03.02.2017 15:50:24
Views:
819
Rating: Antwort:
  Ja
Thema:
Datum in InputBox

Hallo,

eine einfache Lösung unter Verwendung der Regular Expressions:

Option Explicit

'Verweise:
'Microsoft VBScript Regular Expressions 5.5

Private Const REGEX_PATTERN As String = "[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}"
Private Const MAX_TRY As Integer = 5

Public Function get_date() As Date
    Dim strInput As String
    Dim regEx As New RegExp
    Dim i As Integer
    
    With regEx
        .Global = True
        .IgnoreCase = True
        .MultiLine = False
        .Pattern = REGEX_PATTERN
    End With
    
    Do
        i = i + 1
        If i = 1 Then
            strInput = InputBox("Bitte geben Sie ein Datum im Format 'DD.MM.YYYY' ein.", "Datum")
        Else
            strInput = InputBox("Bitte geben Sie ein Datum im Format 'DD.MM.YYYY' ein." & vbCrLf & _
                "Versuch: " & i & " von " & MAX_TRY, "Datum")
        End If
        If i = MAX_TRY Then Exit Do
    Loop Until Not strInput = vbNullString And regEx.test(strInput) And IsDate(strInput)
    
    If Not strInput = vbNullString Then
        get_date = CDate(strInput)
    End If
End Function

Viele Grüße


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
02.02.2017 19:33:50 BlackJack66
NotSolved
02.02.2017 19:55:51 Crazy Tom
NotSolved
03.02.2017 08:16:30 BlackJack66
NotSolved
03.02.2017 07:08:40 GraFri
NotSolved
03.02.2017 08:26:41 BlackJack66
NotSolved
03.02.2017 10:58:32 Gast70117
NotSolved
03.02.2017 13:40:21 BlackJack66
NotSolved
Blau Datum in InputBox
03.02.2017 15:50:24 SJ
NotSolved
03.02.2017 17:21:27 Gast10567
NotSolved
04.02.2017 12:33:51 SJ
NotSolved
04.02.2017 09:02:31 Gast70117
NotSolved
04.02.2017 20:30:12 GraGri
Solved
14.02.2017 08:06:07 BlackJack66
NotSolved