Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

InStr funktioniert nicht

Empfohlene Antworten

Veröffentlicht

Hallo, ich möchte abprüfen ob ein Textfeld eine gültige Zeit enthält


Private Sub txtBegin_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    On Error GoTo ErrorMessage

    Dim strData As String

    Dim nH, nM As Integer

    Dim nPos As Integer

    Dim bResult As Boolean

    Dim dtTime As Date

    strData = Trim(txtBegin.Text)

    bResult = False

    If ((Not (InStr(0, strData, ":", 0) = 0)) Or (Not (InStr(0, strData, ".", 0) = 0))) Then

        nPos = InStr(0, strData, ":")

        nH = CInt(Left(strData, nPos - 1))

        nM = CInt(Right(strData, Len(strData) - (nPos + 1)))

        If (IsNumeric(nH) And IsNumeric(nM)) Then

            If ((nH >= 0 And nH < 23) And (nM > 0 And nM < 59)) Then

                dtTime = TimeSerial(nH, nM, 0)

                bResult = True

            Else

                bResult = False

            End If

        End If

    End If

    If (Not bResult) Then

        MsgBox prompt:="ungültige Zeit", buttons:=vbOKOnly, Title:="Fehler: 006" & "in " & Me.Caption & " txtBegin_Exit"

        txtBegin.setFocus

    End If

    Exit Sub

ErrorMessage:

    MsgBox prompt:=Err.Description, buttons:=vbOKOnly, Title:="Fehler: " & CStr(Err.Number) & "in " & Me.Caption & " txtBegin_Exit"

End Sub

Ich hab das jetzt getestet mit strData = "8:00" nur irgentwie sagt der mir immer:

InStr - Unzulässiger Prozeduraufruf oder ungültiges Argument

Warum ? Vermutlich seh ich den Wald vor lauter Bäumen nicht...

Hi,

"Instr" fängt bei 1 an zu Zählen:


nPos = Instr(1,...) 

Gruß

DevHB

no problem...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.