473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Need to Split 12-Digit Number Field into 12 Separate Fields

1
EXp 290501049125 like this number field i need this to be split 12 fileds like Field1 (2) Field2 (9) filed3 (0) filed4 (5) etc. Can Any one help to solve this issue?
Mar 17 '16 #1
4 1026
jimatqsi
1,271 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. dim x(1 to 12) as string
  2. dim y as string
  3. dim intN1 as int
  4.  
  5. y = "290501049125"
  6. for intN1 = 1 to 11
  7.     x(intN1)=left(y,1) ' take 1 care of Y from the left
  8.     y = mid(y,2)   ' eliminate 1 char at a time from original string
  9. next
  10. x(12)= y
  11.  
Or if you prefer to do it with numbers
Expand|Select|Wrap|Line Numbers
  1. dim x(1 to 12) as integer
  2. dim y as long
  3. dim intN1 as integer
  4.  
  5. y = 290501049125
  6. for intN1 = 1 to 11
  7.     x(intN1)=y-((y/10)*10)
  8.     y=y/10
  9. next
  10. x(12)=y
  11.  
Mar 17 '16 #2
I think this could be simpler if you only use the mid function

Expand|Select|Wrap|Line Numbers
  1. Dim x(1 to 12) as integer
  2. Dim y as String
  3. y = cStr(290501049125)
  4. for i = 1 to len(y)
  5.   x(i) = mid(y,i,1)
  6. next
  7.  
Mar 17 '16 #3
jimatqsi
1,271 Expert 1GB
Yes, Rodney, nicely done. And then it may be advisable to wrap that mid function in a Cint(), thusly
Expand|Select|Wrap|Line Numbers
  1.     x(i) = Cint(mid(y,i,1))
  2.  
Mar 17 '16 #4
ADezii
8,834 Expert 8TB
You can also populate a Table (tblSplit) with the results at the same time:
Expand|Select|Wrap|Line Numbers
  1. Dim y As String
  2. Dim MyDB As DAO.Database
  3. Dim rst As DAO.Recordset
  4. Dim intCtr As Integer
  5.  
  6. Set MyDB = CurrentDb
  7. Set rst = MyDB.OpenRecordset("tblSplit", dbOpenDynaset, dbAppendOnly)
  8.  
  9. y = "290501049125"
  10.  
  11. With rst
  12.   .AddNew
  13.     For intCtr = 1 To 12
  14.       .Fields(intCtr - 1) = Mid$(y, intCtr, 1)
  15.     Next
  16.   .Update
  17. End With
  18.  
  19. rst.Close
  20. Set rst = Nothing
Mar 18 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: shumaker | last post by:
I see other posts where some say fields that will hold a number with leading zeros should be stored as text instead of numbers. This is very inefficient though, as a string of digit characters...
6
by: Tee | last post by:
Hi, Can anyone suggest me a good way to turn a 4 digit number into 24 different sequence in a smart way ? I mean smart way ... actually I not quite sure what I need, but just wonder if anyone...
33
by: Prasad | last post by:
Hi, Can anyone please tell me how to store a 13 digit number in C language ? Also what is the format specifier to be used to access this variable ? Thanks in advance, Prasad P
1
by: Roy | last post by:
I have a table with two fields. I wish to separate all the data in one field and keep it listed against the information in the other field. The information within the field TicketStatus, I wish to...
2
by: dhutton | last post by:
How would one go about grabbing just the last 5 digits of a 16 digit number - then prefixing the last 5 numbers with 99800 so if the number is 8351101100000029 I need my SQL (Microsoft) to grab...
7
by: harijay | last post by:
Hi I am a few months new into python. I have used regexps before in perl and java but am a little confused with this problem. I want to parse a number of strings and extract only those that...
11
by: Jordan218 | last post by:
Hi. How do I write a program that sums the digits of a 4-digit number? I have a program that works, but you have to input the digits separately. Can anyone help or possibly explain what I'm doing...
7
by: abhinuke | last post by:
Been brushing up my C,C++ for my new venture in Graduate Studies for this fall.I am doing basic programs in which I am trying this one right now. A 5-digit positive integer is entered through the...
1
by: Alao Adebisi | last post by:
i want a button to perform a function of checking the last digit number in a field of a table in and add a digit to it and disply it in a textbox.pls
0
by: ema agasta | last post by:
PLEASE,HELP ME how to update the data db2 based on the last digit number 2 ?? for example: EMPNO NAME SALARY 6093 ANA 2300 1139 budi 4500 2393 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.