|
首先为下个月的第一天生成一个顺序数值,然后再减去一天
Private Sub Command1_Click() Dim dtl As Date dtl = DateSerial(Year(Now), Month(Now) + 1, 1) - 1 MsgBox dtl End Sub ------------------------------------------------------------------------------------------- 错误的作法 ==> x = Shell("c:\windows\Sheep.scr") '这种作法只能开启屏幕保护程序的设定画面而已!
正确的作法 ==> Shell ("start c:\windows\sheep.scr") '这种作法才能正确启动屏幕保护程序
------------------------------------------------------------------------------------ Sub mnuEditText_Click (Index As Integer) ' 我们只要使用 SendKeys,其他的就让 Windows 去做吧! Select Case Index Case 0 '复原/UNDO SendKeys "^Z" 'Keys Ctrl+Z Case 1 '剪下/CUT SendKeys "^X" 'Keys Ctrl+X Case 2 '复制/COPY SendKeys "^C" 'Keys Ctrl+C Case 3 '贴上/PASTE SendKeys "^V" 'Keys Ctrl+V End Select End Sub
------------------------------------------------------------------------------------- Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
'加入以下程序码:
Private Sub Command1_Click() MsgBox "计时器停掉了!", 64, "VB 的讯息框" End Sub
Private Sub Command2_Click() Timer1.Enabled = 1 MessageBox Me.hwnd, "注意!计时器还在跑!", "API 的讯息框", 64
End Sub
Private Sub Form_Load() Timer1.Interval = 2000 Label1.Caption = "目前的时间是:" & Time End Sub
Private Sub Timer1_Timer() SendKeys Chr(13) Timer1.Enabled = 0 End Sub
|