史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 軟體應用問題討論區
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


 
 
主題工具 顯示模式
舊 2005-03-22, 03:13 PM   #1
cocoking
註冊會員
榮譽勳章
UID - 79625
在線等級: 級別:13 | 在線時長:235小時 | 升級還需:17小時級別:13 | 在線時長:235小時 | 升級還需:17小時級別:13 | 在線時長:235小時 | 升級還需:17小時
註冊日期: 2003-06-21
VIP期限: 2009-10
文章: 60
精華: 0
現金: 5588 金幣
資產: 10588 金幣
Question 會寫VB的大大請進來看一下

小弟想寫個「萬年曆」加上「備忘錄」的功能
在萬年曆的部分就卡住了(紅色字為偵錯部份)
如果取消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
cocoking 目前離線  
送花文章: 74, 收花文章: 1 篇, 收花: 1 次
回覆時引用此帖
 



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 11:04 AM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1