I am using
IsNumeric to check if a part of a variable are numbers or not. Unfortunately it only seems to check the first character of the string part instead of the whole bit.
It currently accepts i.e. Q123 1234567 and QWER 1QWERTYR (and other varients of that). While I need the first 4 characters to be all letters and the others to be all numbers.
I have no idea what I am missing still. Please add extra comments if at all possible, my understanding of vba is below basic still.
Dim ConNr As String Dim Space As String Dim Four As String Dim Six As String Dim One As String Dim Container As String ConNr = Me.txtContainer.Value Space = " " Four = Left(Me.txtContainer.Value, 4) Four = UCase(Four) Six = Mid(Me.txtContainer.Value, 5, 6) One = Right(Me.txtContainer.Value, 1) 'Check if all 4 are letters If IsNumeric(Four) = True Then MsgBox "First 4 need to be letters." Me.txtContainer.SetFocus Exit Sub Else 'MsgBox "Four Letters " Four 'Check if 6 characters are numbers If IsNumeric(Six) = False Then MsgBox "4 Letters followed by 6 numbers." 'MsgBox "These Six " Six Me.txtContainer.SetFocus Exit Sub Else 'MsgBox "Six Numbers " Six 'Last number is number If IsNumeric(One) = False Then MsgBox "Last character needs to be a number." Me.txtContainer.SetFocus Exit Sub Else 'MsgBox "Last Number " One ConNr = Four & Space & Six & Space & One Container = ConNr End If End If End If