VB6 to VB.Net Conversion

G

Guest

Could someone please help me converting the following lines of vb6 code to
vb.net. The message box should display "1/3/2005" if it is executed today.

Private Sub Form_Load()
Dim nWeekNumber As Integer
Dim ThisYearStart As Date
ThisYearStart = YearStart(Today, 2)
msgbox ThisYearStart
End Sub

Function YearStart(WhichYear As Integer) As Date
Dim WeekDay As Integer
Dim NewYear As Date
NewYear = DateSerial(WhichYear, 1, 1)
WeekDay = (NewYear - 2) Mod 7
If WeekDay < 4 Then
YearStart = NewYear - WeekDay
Else
YearStart = NewYear - WeekDay + 7
End If
End Function
 
D

Diggers

At a glance (I'm playing a poker tourney at the moment .. hehe), the
equivelant to Today is DateTime.Now.

You should also look into DateTime and TimeSpan classes as they have
made a of stuff that was inconvenient (read: tedious) in Classic VB
obsolete.

Cheers
Simon

p.s. if this really doesn't help let me knowm and I'll look for
thoroughly when I'm not playing cards.

Cheers

Simon Rigby.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top