Removing old VB code

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
Hi, I have removed the dll reference to ensure I am using only .NET code and am suprised at how much of the old stuff litters my app!!

I have successfully removed all refereces to vbcrlf to system.environment.newline but am stuffed slightly on the date issues.

I have found I have used the old Today and DateAdd etc functions and now get compile errors showing me where I need to make changes.

I am stuck on trying to subtract 3 months from the current date!

Can someone point me in the right direction on how to do this please?

Thanks
 
VB.NET:
Dim ThreeMonthsAgo As Date = Date.Now.AddMonths(-3)
 
Is there a replacement for monthname(n)?

I have trawled the forum and the online help and am drawing a blank!:confused:

I found this but cannot get it to work?

DateTimeFormatInfo.MonthNames
 
aha :D

got it

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dtfDateTimeInfo [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DateTimeFormatInfo
[/SIZE][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE] 
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strMonthNames [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]()
[/SIZE][SIZE=2][COLOR=#008000][/COLOR][/SIZE] 
[SIZE=2][COLOR=#008000]' get an array of the month names
[/COLOR][/SIZE][SIZE=2] 
strMonthNames.Equals(dtfDateTimeInfo.MonthNames)
[/SIZE]
 
Equals is a comparison function. Do this instead:
VB.NET:
Dim names() As String = Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames
MsgBox(names(Date.Now.Month - 1))
 
Back
Top