Format a Postcode...... 4 3 format
API Declarations
Function FormatPostcode(myOriginalPostcode As String)
'Need Some Code? Request it at www.SmokeCrack.co.uk
Dim myCount As Integer
myCount = 0
Do
myCount = myCount + 1
If InStr(1, myOriginalPostcode, " ") <> 0 Then
myOriginalPostcode = Left(myOriginalPostcode, InStr(myOriginalPostcode, " ") - 1) & Mid(myOriginalPostcode, InStr(1, myOriginalPostcode, " ") + 1, 100)
End If
Loop Until InStr(1, myOriginalPostcode, " ") = 0
'START CHECKING LENGTH OF POSTCODE
If Len(myOriginalPostcode) = 7 Then
myOriginalPostcode = Left(myOriginalPostcode, 4) & " " & Right(myOriginalPostcode, 3)
End If
If Len(myOriginalPostcode) = 6 Then
If IsNumeric(Mid(myOriginalPostcode, 2, 1)) = True Then
'B 40 0DP
myOriginalPostcode = Left(myOriginalPostcode, 1) & " " & Mid(myOriginalPostcode, 2, 2) & " " & Right(myOriginalPostcode, 3)
Else:
'BN 4 0DP
myOriginalPostcode = Left(myOriginalPostcode, 2) & " " & Mid(myOriginalPostcode, 3, 1) & " " & Right(myOriginalPostcode, 3)
End If
End If