永发信息网

vb 程序设计 关于一个日历程序的问题

答案:2  悬赏:80  手机版
解决时间 2021-08-14 02:34

Dim selectedate%

Private Sub cbomonth_click()
Call setday
Call lblnumber_click(selectedate% - 1)
End Sub

Private Sub cboyear_Click()
Static once% ' 改变年度
If Not once Then
    once = True
    Exit Sub
End If
Call cbomonth_click

End Sub

Private Sub checkdate(month1%, year1%)
Dim i%, value%, date1$

For i% = 28 To 32
    date1$ = (Str$(month1%) + "/" + Str$(i%) + "/" + Str$(year1%))
        If IsDate(date1$) Then
            value% = i%
        Else
            Call displaynumbers(value%)
            Exit Sub
        End If
Next i%
End Sub

Private Sub cmdcancel_Click()
Unload frmcalendar
End Sub

Private Sub cmdok_Click()
Dim month1%, day1%, year1%, date1$
day1% = selectedate%
month1% = cbomonth.ListIndex + 1
year1% = cboyear.ListIndex + 1960
date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
date1$ = Format$(date1$, "general date")

MsgBox Format$(date1$, "long date") '显示你选择的日期

End Sub

Private Function determinemonth%()
Dim i%
i% = cbomonth.ListIndex '选择的月份
determinemonth% = i% + 1
End Function

Private Function determineyear%()
Dim i%
i% = cboyear.ListIndex '选择的年度
If i% = -1 Then Exit Function
determineyear% = CInt(Trim(cboyear.List(i%)))
End Function

Private Sub displaynumbers(number%)
Dim i%
For i% = 28 To 30
    lblnumber(i%).Visible = False
Next i%
For i% = 28 To number% - 1
    lblnumber(i%).Visible = True
Next i%

End Sub

Private Sub fillcbomonth()
cbomonth.AddItem "一月"
cbomonth.AddItem "二月"
cbomonth.AddItem "三月"
cbomonth.AddItem "四月"
cbomonth.AddItem "五月"
cbomonth.AddItem "六月"
cbomonth.AddItem "七月"
cbomonth.AddItem "八月"
cbomonth.AddItem "九月"
cbomonth.AddItem "十月"
cbomonth.AddItem "十一月"
cbomonth.AddItem "十二月"
End Sub

Private Sub fillcboyear()
Dim i%
For i% = 1960 To 2060 '填充年度
    cboyear.AddItem Str$(i%)
Next i%

End Sub

Private Sub Form_Load()

selectedate% = CInt(Format$(Now, "dd"))

'填充月份下拉框
Call fillcbomonth

'填充年份下拉框
Call fillcboyear

'设置当前时间
Call setdate

'显示当前是星期几
Dim caption1$
Dim r As Integer
r = Weekday(Date)
If r = 1 Then
    caption1$ = "星期天"
ElseIf r = 2 Then
    caption1 = "星期一"
ElseIf r = 3 Then
    caption1 = "星期二"
ElseIf r = 4 Then
    caption1 = "星期三"
ElseIf r = 5 Then
    caption1 = "星期四"
ElseIf r = 6 Then
    caption1 = "星期五"
Else
    caption1 = "星期六"
End If
lblday.Caption = caption1$

End Sub

Private Sub lblnumber_click(Index As Integer)
Dim i%
On Error GoTo err1
For i% = 0 To 30
    lblnumber(i%).BorderStyle = 0
Next i%
If lblnumber(Index).BorderStyle = 1 Then
    lblnumber(Index).BorderStyle = 0
Else
    lblnumber(Index).BorderStyle = 1
End If
selectedate% = Index + 1
Dim month1%, day1%, year1%, date1$
day1% = selectedate%
month1% = cbomonth.ListIndex + 1
year1% = cboyear.ListIndex + 1960
date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
Dim r%
Dim caption1$
r% = Weekday(date1$)
If r% = 1 Then
    caption1$ = "星期天"
ElseIf r% = 2 Then
    caption1 = "星期一"
ElseIf r% = 3 Then
    caption1 = "星期二"
ElseIf r% = 4 Then
    caption1 = "星期三"
ElseIf r% = 5 Then
    caption1 = "星期四"
ElseIf r% = 6 Then
    caption1 = "星期五"
Else
    caption1 = "星期六"
End If
lblday.Caption = caption1$
lbldate.Caption = Format$(date1$, "long date")

err1:
    If Err = 0 Then Exit Sub
    If Err = 13 Then
        selectedate% = selectedate% - 1
    Exit Sub
    End If
    End Sub

Private Sub setdate()
'年份
Dim r%, i%
r% = CInt(Format$(Now, "yyyy"))
i% = r% - 1960
cboyear.ListIndex = i%

'月份
r% = CInt(Format$(Now, "mm"))
cbomonth.ListIndex = (r% - 1)

'日期
r% = CInt(Format$(Now, "dd"))
lblnumber(r% - 1).BorderStyle = 1
selectedate% = r%

End Sub

Private Sub setday()
Dim month1%, year1%
month1% = determinemonth()
year1% = determineyear()
Call checkdate(month1%, year1%)
End Sub

谁能详细解释一下这段程序

最佳答案
是个会VB的都能 只不过段落太长 没人会理你的了 这已经不是问问题了 这都可以立项目了 不信的话等着看看
全部回答

差不多,太长没心思写

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
耶稣为什么会被绑在十字架上呢?
华龙区濮阳品男名店地址有谁知道?有点事想过
四川农村信用卡查询帐户余额能不能在手机上查
epc灯亮是哪里的故障
关于龙之谷魔导师的闪现使用
怎么坐着减肥,在校高中生如何减肥,每天都是
HS怎样加点好?高手多指点.
幸运金币有什么用】
明明已经放下了,明明已经不爱他了,为什么还
香坊区哈尔滨天朗医药连锁地址在哪,我要去那
谁能告诉我这2种字体的名字
魔兽开80以后什么职业当T最好
怎么开摄像头啊
天津市哪能买到天津医科大学成人高考考试辅导
severe的比较级到底是加er还是more啊?
推荐资讯
梦幻宠物成长问题、
我是徐州的,请问电脑入网的流程、费用(必须
半夜牙齿疼。怎么办
培根语录,不是出自培根的名言的是?如果你把快
中国的发动机完善吗?
关于这篇文章的问题1.第六自然段中的“有些事
通河县哈尔滨燕子海鲜烧烤城这个地址怎么能查
近日发现有很多网友转发打电话中话费的日志,
爱运动的英语句子,关于爱花的句子
AABC式的成语帮帮我成功成功成功成功成功成功
iphone4 有什么弊端吗,请教了
距离把两个人相爱的人隔开,那么年龄呢?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?