473,386 Members | 1,610 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,386 software developers and data experts.

how collecting 1 + TW000001 To Get TW000002

hello

how collecting 1 + TW000001 To Get TW000002
Or
300 + TW000200 To Get TW000500
What ever

i need this code


Thanks
Jun 24 '07 #1
3 922
Wing
28
Expand|Select|Wrap|Line Numbers
  1. Dim a As String = "TW000001"
  2. Dim b As String = Microsoft.VisualBasic.Left(a, Len(a) - 1)
  3. Dim c As Integer = CInt(Microsoft.VisualBasic.Right(a, 1))
  4. c = c + 1
  5. Dim d As String = b + c.ToString
You can modify this code to compensate for 2, 3, or 4 digit number by looking for the last instance of zero. Or just chop TW and fill in the leading zeros. Hope this gets you started.
Jun 24 '07 #2
thanks my friend i will do
Jun 25 '07 #3
Frinavale
9,735 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Dim a As String = "TW000001"
  2. Dim b As String = Microsoft.VisualBasic.Left(a, Len(a) - 1)
  3. Dim c As Integer = CInt(Microsoft.VisualBasic.Right(a, 1))
  4. c = c + 1
  5. Dim d As String = b + c.ToString
You can modify this code to compensate for 2, 3, or 4 digit number by looking for the last instance of zero. Or just chop TW and fill in the leading zeros. Hope this gets you started.
Although this solution may work, I would suggest using code that is a bit more flexible for your situation.

What you really want to do is trim the "TW" off of your number, convert the number (which is a currently a String) into an Integer, add that integer to some value, and then put the whole thing back together with your number formatted in such a way that it shows 6 digits and starts with "TW".

The following code will do that for you:

Expand|Select|Wrap|Line Numbers
  1. Dim additionNumber As Integer = 1
  2. Dim originalStr As String = "TW000001"
  3. 'grabbing 000001, which starts at index 2 (vb) in the String
  4. Dim numberStr As String = originalStr .Substring(2)
  5. Try
  6.     Dim myNumber As Integer =Integer.Parse(numberStr)
  7.     Dim newNumber As Integer = additionNumber + myNumber
  8.     'The following line will format the newNumber to show 6 digits at all times
  9.     'If the number is less than 6 digits, the number is padded with 0s to its left
  10.     'The newString will then hold "TW" + a number that is 6 digits long
  11.     Dim newString As String = "TW" + newNumber.ToString.PadLeft(6, "0")
  12. Catch ex As Exception
  13.     'couldn't create a number based on the string provided to Integer.Parse()
  14. End Try
  15.  
Enjoy!

-Frinny
Jun 25 '07 #4

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

Similar topics

1
by: nt9 | last post by:
I am very new with php so excuse me please if the question seems really easy.I have a page(form) which displays a list of the titles of some books(retreived from a database) and each title has a...
2
by: serge calderara | last post by:
dear all, I am building an application which is collecting data from a database and display them in a windows form. My idea is to collect those data in a form that, they can be read by my...
10
by: Robert Potthast | last post by:
Hi! I am trying to implement a safe garbage collecting system. I use reference counting combined with smart pointers and a garbage collector which keeps a list of all heap-allocated objects. Now I...
2
by: David | last post by:
Sorry about the previous question. The thing I am really trying to do is collecting HTML id's on a given form. As you may know, ASP.NET control ids do not necessarily match html control names...
12
by: pmclinn | last post by:
How would you access a cookie value from a windowsform? This is how I do it from asp.net: If Not Request.Cookies("RunNodeReport") Is Nothing Then ...
0
by: Antal Rutz | last post by:
Hi all, I'd like to collect snmp data from varoius network devices parallel. First I tried with my own threadpool class then I gave a try to Christopher Arndt's threadpool.py...
17
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also...
5
by: Phil | last post by:
What methods do we have of collecting information about browsing history? We would like to see the last few links that a client followed, prior to entering our site. I thought $_SERVER object...
1
by: Bob Alston | last post by:
Looking for design approach ideas for collecting data from multiple remote, standalone databases. I have built one of these in Access. Another I am told was built in Access. some others the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.