devxlogo

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

' Increment the numeric right-most portion of a string' Example: MessageBox.Show(IncrementString("test219")) ' => 220Function 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 IfEnd Function

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.