dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Intermediate
Jun 30, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


IncrementString- Incrementing the numeric right-most portion of a string

' Increment the numeric right-most portion of a string
' Example: MessageBox.Show(IncrementString("test219")) ' => 220

Function IncrementString(ByVal text As String) As String
    Dim index As Integer
    Dim i As Integer
    For i = text.Length - 1 To 0 Step -1
        Select Case text.Substring(i, 1)
            Case "0" To "9"
            Case Else
                index = i
                Exit For
        End Select
    Next

    If index = text.Length - 1 Then
        Return text & "1"
    Else
        Dim value As Integer = Integer.Parse(text.Substring(index + 1)) + 1
        Return text.Substring(0, index) & value.ToString()
    End If
End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date