6 digits

# Thread: 6 digits

1. its
Senior Member
Join Date
Dec 1969
Posts
238

## 6 digits

I have to read values from An Access tableA and insert them into another TableB. In TableA the values are like this 64598, 2345, 222343....(some are 5 digits some are 4 digits some are 6 digits)<BR><BR>I have to insert these values in TableB as "6 DIGIT" values like if the value from TableA is 4 digit (1234) and i need to add 2 Zeros at the last(123400) and insert into TableB like same way if i have 5 digit (34562) i have to add 1 Zero at the last (345620), please help me to do this

2. Senior Member
Join Date
Dec 1969
Posts
733

## Quick and dirty

Probably there is a better way, but this should work<BR><BR>newNumber = cInt(Left(CStr(oldNumber) & "000000"), 6)

3. Senior Member
Join Date
Dec 1969
Posts
5,955

## Do padding in VBScript or even...

...in the SQL statement.<BR><BR>In VBScript:<BR><BR>Dim sTableA, sTableB<BR><BR>sTableA = "1234"<BR>sTableB = Left(sTableA & "000000", 6)<BR><BR>In SQL (if you&#039;re using Access at least):<BR><BR>INSERT INTO ... VALUE ... Left(TableA.Field & "000000", 6) ...<BR><BR>Oliver.

4. its
Senior Member
Join Date
Dec 1969
Posts
238

## RE: Do padding in VBScript or even...

Thanks for your quick response. <BR>One more question for the same...<BR>I need the SYNTAX for to put Zeros infront of my values like 001234, 012345, 000232....

5. Senior Member
Join Date
Dec 1969
Posts
733

## RE: Do padding in VBScript or even...

Try guessing! Hint: use right instead of left and add the &#039;000000&#039; string to the front!

6. Senior Member
Join Date
Dec 1969
Posts
5,955

## Come on, this is easy. Try...

...this:<BR><BR>Dim sTableA, sTableB <BR><BR>sTableA = "1234" <BR>sTableB = Right("000000" & sTableA, 6)<BR><BR>Next time try it for yourself though. We are busy people here. :-)<BR><BR>Oliver.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•