請教各位高手,我在使用記事本時,會每隔二個月就要求我執行一次記事本功能,但我是要在需要時才建立記事本,附上程式碼,請各位幫我解答,謝謝!
Option Explicit
Const N As Integer = 15 '圖片數目
Dim pattern(N - 1) As String '圖片名稱陣列
Private Sub Form_Initialize() '表單啟始
'消除在MonthView控制項所出現的下個月日期顯示
MonthView1.TrailingForeColor = RGB(255, 255, 255)
ChangeImage '改變圖片
End Sub
Private Sub Form_Load() '表單載入
Dim i As Integer
pattern(0) = "01.jpg"
pattern(1) = "02.jpg"
pattern(2) = "03.jpg"
pattern(3) = "04.jpg"
pattern(4) = "05.jpg"
pattern(5) = "06.jpg"
pattern(6) = "07.jpg"
pattern(7) = "08.jpg"
pattern(8) = "09.jpg"
pattern(9) = "10.jpg"
pattern(10) = "11.jpg"
pattern(11) = "12.jpg"
pattern(12) = "13.jpg"
pattern(13) = "14.jpg"
pattern(14) = "15.jpg"
Randomize '亂數產生啟始
End Sub
Private Sub Form_Resize() '表單改變大小
'表單縮小化?
If Form1.WindowState = vbMinimized Then
Form1.Caption = "風景月曆" & Date
'表單一般化?
ElseIf Form1.WindowState = vbNormal Then
'調整Image控制項位置
Image1.Left = Form1.ScaleLeft
Image1.Top = Form1.ScaleTop + 200
Image1.Width = MonthView1.Width
Image1.Height = MonthView1.Height + 200
Image1.Visible = True
'調整MonthView控制項位置
Form1.Caption = "風景月曆"
MonthView1.MonthRows = 1
MonthView1.MonthColumns = 1
MonthView1.Left = Form1.ScaleLeft
MonthView1.Top = Form1.ScaleHeight / 2 + 100
Form1.Width = MonthView1.Width + 100
'調整表單最大化?
ElseIf Form1.WindowState = vbMaximized Then
'改變月曆顯示為半年方式顯示
Form1.Caption = "風景月曆"
MonthView1.MonthRows = 3
MonthView1.MonthColumns = 2
'將月曆置於表單中央
MonthView1.Left = (Form1.ScaleWidth - MonthView1.Width) / 2
MonthView1.Top = (Form1.ScaleHeight - MonthView1.Height) / 2
Image1.Visible = False
End If
End Sub
Public Sub ChangeImage() '改變圖片
Dim num As Integer
num = Int(Rnd * N) '產生範圍在0~15之間的亂數
'設定Image控制項的圖片檔名
Image1.Picture = LoadPicture(App.Path & "\vb_picture\" & pattern(num))
End Sub
'切換不同的月份
Private Sub MonthView1_DblClick()
Dim s, FileName As String
Dim yr, mon As Integer
s = MonthView1.Value '讀取今日日期
If Len(s) > 0 Then
FileName = yr & mon & s & ".txt" '組合檔案名稱
Shell "NotePad" & " " & FileName, vbNormalFocus '開啟NotePad
End If
End Sub
Private Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Integer, State() As Boolean)
If Form1.WindowState = vbNormal Then
ChangeImage
End If
End Sub
Option Explicit
Const N As Integer = 15 '圖片數目
Dim pattern(N - 1) As String '圖片名稱陣列
Private Sub Form_Initialize() '表單啟始
'消除在MonthView控制項所出現的下個月日期顯示
MonthView1.TrailingForeColor = RGB(255, 255, 255)
ChangeImage '改變圖片
End Sub
Private Sub Form_Load() '表單載入
Dim i As Integer
pattern(0) = "01.jpg"
pattern(1) = "02.jpg"
pattern(2) = "03.jpg"
pattern(3) = "04.jpg"
pattern(4) = "05.jpg"
pattern(5) = "06.jpg"
pattern(6) = "07.jpg"
pattern(7) = "08.jpg"
pattern(8) = "09.jpg"
pattern(9) = "10.jpg"
pattern(10) = "11.jpg"
pattern(11) = "12.jpg"
pattern(12) = "13.jpg"
pattern(13) = "14.jpg"
pattern(14) = "15.jpg"
Randomize '亂數產生啟始
End Sub
Private Sub Form_Resize() '表單改變大小
'表單縮小化?
If Form1.WindowState = vbMinimized Then
Form1.Caption = "風景月曆" & Date
'表單一般化?
ElseIf Form1.WindowState = vbNormal Then
'調整Image控制項位置
Image1.Left = Form1.ScaleLeft
Image1.Top = Form1.ScaleTop + 200
Image1.Width = MonthView1.Width
Image1.Height = MonthView1.Height + 200
Image1.Visible = True
'調整MonthView控制項位置
Form1.Caption = "風景月曆"
MonthView1.MonthRows = 1
MonthView1.MonthColumns = 1
MonthView1.Left = Form1.ScaleLeft
MonthView1.Top = Form1.ScaleHeight / 2 + 100
Form1.Width = MonthView1.Width + 100
'調整表單最大化?
ElseIf Form1.WindowState = vbMaximized Then
'改變月曆顯示為半年方式顯示
Form1.Caption = "風景月曆"
MonthView1.MonthRows = 3
MonthView1.MonthColumns = 2
'將月曆置於表單中央
MonthView1.Left = (Form1.ScaleWidth - MonthView1.Width) / 2
MonthView1.Top = (Form1.ScaleHeight - MonthView1.Height) / 2
Image1.Visible = False
End If
End Sub
Public Sub ChangeImage() '改變圖片
Dim num As Integer
num = Int(Rnd * N) '產生範圍在0~15之間的亂數
'設定Image控制項的圖片檔名
Image1.Picture = LoadPicture(App.Path & "\vb_picture\" & pattern(num))
End Sub
'切換不同的月份
Private Sub MonthView1_DblClick()
Dim s, FileName As String
Dim yr, mon As Integer
s = MonthView1.Value '讀取今日日期
If Len(s) > 0 Then
FileName = yr & mon & s & ".txt" '組合檔案名稱
Shell "NotePad" & " " & FileName, vbNormalFocus '開啟NotePad
End If
End Sub
Private Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Integer, State() As Boolean)
If Form1.WindowState = vbNormal Then
ChangeImage
End If
End Sub
全站熱搜
留言列表