Solved

error in string.

Posted on 2007-04-02
1
137 Views
Last Modified: 2010-04-16
If I put 200401

it gives me 20042





Public Function IncrementDate(ByVal DtPeriod As String, ByVal IncrementAmount As Integer) As String

Dim strResults As String

Dim intYear As Integer

Dim intMonth As Integer

intYear = Int32.Parse(DtPeriod.Substring(0, 4))

intMonth = Int32.Parse(DtPeriod.Substring(4, 2))

intMonth += IncrementAmount

If intMonth > 12 Then

intYear += 1

intMonth -= 12

End If

strResults = intYear.ToString & intMonth.ToString

Return strResults

End Function
0
Comment
Question by:mathieu_cupryk
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18838841
that is because int.Tostring does not keep leading 0

strResults = intYear.ToString & intMonth.ToString().PadLeft(2, "0")
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question