![]() |
|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
![]() |
#1 |
註冊會員
|
![]() 小弟想寫個「萬年曆」加上「備忘錄」的功能
在萬年曆的部分就卡住了(紅色字為偵錯部份) 如果取消Private Sub nYear_Change()就能執行,不過當年改變時日曆不會更新 月則會 不知道問題出來哪?(command1(0~41)為顯示日期的 command button,日後還要作備忘錄的功能) 請大大幫忙看一下(form跟textbox我就不po了,跟除錯沒有關係) Private Sub Command2_Click() '按一下此鍵年減1 nYear.Text = nYear.Text - 1 End Sub Private Sub Command3_Click() '按一下此鍵年加1 nYear.Text = nYear.Text + 1 End Sub Private Sub Command4_Click() '按一下此鍵月減1如果月<1 則月=12且年減1 nMonth.Text = nMonth.Text - 1 If nMonth.Text < 1 Then nMonth.Text = 12 nYear.Text = nYear.Text - 1 End If End Sub Private Sub Command5_Click() '按一下此鍵月加1如果月>12則月=1年加1 nMonth.Text = nMonth.Text + 1 If nMonth.Text > 12 Then nMonth.Text = 1 nYear.Text = nYear.Text + 1 End If End Sub Function getMMdays(pnYear, pnMonth) '定義每月的總天數 Select Case pnMonth Case 1, 3, 5, 7, 8, 10, 12 getMMdays = 31 Case 4, 6, 9, 11 getMMdays = 30 Case 2 If (pnYear Mod 4) = 0 Then If (pnYear Mod 100) = 0 Then If (pnYear Mod 400) = 0 Then getMMdays = 29 Else getMMdays = 28 End If Else getMMdays = 29 End If Else getMMdays = 28 End If End Select End Function Function getWeekday(pnYear, pnMonth) '自定函數求每月的第一天星期為? getWeekday = Weekday(DateSerial(pnYear, pnMonth, 1)) End Function Private Sub Form_Load() '表格load nYear.Text = Year(Now) nMonth.Text = Month(Now) nMdays = getMMdays(CInt(nYear.Text), CInt(nMonth.Text)) nWday = getWeekday(CInt(nYear.Text), CInt(nMonth.Text)) Call showMonth(nMdays, nWday) End Sub Function showMonth(pnMdays, pnWday) '定義函數顯示日曆 pnMdays = getMMdays(CInt(nYear.Text), CInt(nMonth.Text)) - 1 pnWday = getWeekday(CInt(nYear.Text), CInt(nMonth.Text)) For I = 0 To pnMdays Command1(pnWday - 1 + I).Caption = I + 1 Next I End Function Private Sub nMonth_Change() '月份改變時更新日曆 If nMonth.Text = "" Then nMonth.Text = Month(Now) End If For I = 0 To 41 Command1(I).Caption = "" Next I nMdays = getMMdays(CInt(nYear.Text), CInt(nMonth.Text)) nWday = getWeekday(CInt(nYear.Text), CInt(nMonth.Text)) Call showMonth(nMdays, nWday) End Sub Private Sub nYear_Change() '年份改變時更新日曆 If nYear.Text = "" Then nYear.Text = Year(Now) End If For I = 0 To 41 Command1(I).Caption = "" Next I nMdays = getMMdays(CInt(nYear.Text), CInt(nMonth.Text)) nWday = getWeekday(CInt(nYear.Text), CInt(nMonth.Text)) Call showMonth(nMdays, nWday) End Sub |
![]() |
送花文章: 74,
![]() |