Solved

error in string.

Posted on 2007-04-02
1
135 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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now