Solved Update Query to Add Missing 0 at the front of a telephone number?

Number11

Member
Local time
Today, 09:04
Joined
Jan 29, 2020
Messages
625
Is it possible to have an update query to add a missing 0 to a telephone number
 
I'm sure it's possible, but how do you determine that 0 is missing?

This may apply

Code:
' ----------------------------------------------------------------
' Procedure Name: addZeros
' Purpose: Routine to add leading 0's to a string
' Procedure Kind: Function
' Procedure Access: Public
' Parameter makeLonger (String): the original string
' Parameter numberDigits (): length of required output FINAL STRING)
' Return Type: String
' Author: Jack from internet
' Date: 09-Feb-22
' ----------------------------------------------------------------
Public Function addZeros(makeLonger As String, numberDigits) As String
    Dim x
    'Adds 0's Leading 0 Leading zero to the front of the number until it's the correct length
    'Change "0" to another character if you need a different character than 0
    For x = 1 To (numberDigits - Len(makeLonger))
        makeLonger = "0" & makeLonger
    Next x
    addZeros = makeLonger
End Function

Sample usage:

?addzeros("345",8)
00000345
 
Last edited:
Can't you just use Format()?
Code:
tt=1792555147
? tt
 1792555147 
? format(tt,"00000000000")
01792555147
 
I'm sure it's possible, but how do you determine that 0 is missing?

This may apply

Code:
' ----------------------------------------------------------------
' Procedure Name: addZeros
' Purpose: Routine to add leading 0's to a string
' Procedure Kind: Function
' Procedure Access: Public
' Parameter makeLonger (String): the original string
' Parameter numberDigits (): length of required output FINAL STRING)
' Return Type: String
' Author: Jack from internet
' Date: 09-Feb-22
' ----------------------------------------------------------------
Public Function addZeros(makeLonger As String, numberDigits) As String
    Dim x
    'Adds 0's Leading 0 Leading zero to the front of the number until it's the correct length
    'Change "0" to another character if you need a different character than 0
    For x = 1 To (numberDigits - Len(makeLonger))
        makeLonger = "0" & makeLonger
    Next x
    addZeros = makeLonger
End Function

Sample usage:

?addzeros("345",8)
00000345
Did the job thanks
 
Happy to help.
 

Users who are viewing this thread

Back
Top Bottom