Solved

error in string.

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

17 Experts available now in Live!

Get 1:1 Help Now