VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Format a Postcode...... 4 3 format

by SCC (9 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 10th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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

Rate Format a Postcode...... 4 3 format



'Need Some Code???  Request it at www.SmokeCrack.co.uk

Msgbox FormatPostcode("BN89PO")

'Will return BN 8 9PO

End Sub

Download this snippet    Add to My Saved Code

Format a Postcode...... 4 3 format Comments

No comments have been posted about Format a Postcode...... 4 3 format. Why not be the first to post a comment about Format a Postcode...... 4 3 format.

Post your comment

Subject:
Message:
0/1000 characters