急求vb.net中根据日月星期推算年,在线等
vb.net中根据日月星期推算是那一年的方法,求源码
[解决办法]
有2种方案
1。建数据库,通过搜索来实现,优点,完全没有难度,任何数值可以自行设定
2。通过MonthView控件实现,让他输入日月和星期后,首先从当年开始判断,vb代码如下:
MonthView1.Month = Val(txtMonth)
MonthView1.Day = Val(txtDay)
year=2007
For i = year To 1980 Step -1
MonthView1.Year = i
If MonthView1.DayOfWeek = Val(txtDayOfWeek) Then Exit For
Next
txtYear = i
[解决办法]
慢了,lz,我想复杂了,这个题20分足够了。
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Int32 = 0 To 11
ComboBox1.Items.Add(i + 1 & "月 ")
Next
For i As Int32 = 0 To 31
ComboBox2.Items.Add(i + 1 & "日 ")
Next
With ComboBox3.Items
.Add( "星期日 ")
.Add( "星期一 ")
.Add( "星期二 ")
.Add( "星期三 ")
.Add( "星期四 ")
.Add( "星期五 ")
.Add( "星期六 ")
End With
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
ComboBox3.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = (ComboBox1.SelectedIndex + 1) & "- " & (ComboBox2.SelectedIndex + 1)
Dim r As String = " "
For i As Int32 = 1900 To 2100
Dim s As String = i & "- " & str
Dim d As Date = CDate(s)
If d.DayOfWeek = ComboBox3.SelectedIndex Then
r += i & ", "
End If
Next
r = r.TrimEnd( ", ")
TextBox1.Text = r
End Sub
End Class