帮忙用VB平台做一个倒计时的小程序。。。就是距离国庆节还有xx天xx时xx分。。这种东西谢谢
展开全部
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
Label1.AutoSize = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
d = "2011-10-1"
Label1.Caption = "距离国庆节〔" & Format(d, "yyyy年m月d日") & "〕还有" & DateDiff("n", Now, d) \ 1440 & "天" & Format(CDate(d) - Now, "h时m分s秒")
End Sub
Timer1.Interval = 1000
Timer1.Enabled = True
Label1.AutoSize = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
d = "2011-10-1"
Label1.Caption = "距离国庆节〔" & Format(d, "yyyy年m月d日") & "〕还有" & DateDiff("n", Now, d) \ 1440 & "天" & Format(CDate(d) - Now, "h时m分s秒")
End Sub
展开全部
'/////////////// API函数声明
'/////////////// 获取用户名
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'/////////////// 访问注册表
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_SZ = 1
'/////////////// 自定义函数
'/////////////// 添加到注册表中的开机启动
Public Function AddToStarup(DesName As String, exePath As String) As Boolean
Dim SubKey As String
Dim hKey As Long
On Error GoTo acd
AddToStarup = False
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run"
RegCreateKey HKEY_CURRENT_USER, SubKey, hKey
RegSetValueEx hKey, DesName, 0, REG_SZ, ByVal exePath, LenB(StrConv(exePath, vbFromUnicode)) + 1
RegCloseKey hKey
AddToStarup = True
Exit Function
acd:
AddToStarup = False
End Function
'/////////////// 右下角显示托盘图标+设置开机自动运行
Private Sub Check1_Click()
If Check1 Then '当选择框被选中时
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
'定义鼠标移动到托盘上时显示的Tip
.szTip = App.Title + "(版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide '添加到这里的代码,只要点击选择框,程序就会最小化到任务栏
Call AddToStarup("IP查看器", App.Path & "\IP查看器.exe") '这里是在系统启动时打开本程序
End If
End Sub
'/////////////// 设置剪贴板文本
Private Sub Command1_Click()
Clipboard.Clear
Clipboard.SetText Text1.Text '这里是复制text1的文本
End Sub
Private Sub Command2_Click()
Clipboard.Clear
Clipboard.SetText Text2.Text '这里是复制text2的文本
End Sub
Private Sub Command3_Click()
Clipboard.Clear
Clipboard.SetText Text3.Text '这里是复制text3的文本
End Sub
Private Sub Command4_Click()
Clipboard.Clear
Clipboard.SetText Text4.Text '这里是复制text4的文本
End Sub
'/////////////// 通过WinSocket控件获取本地IP地址
Private Sub Command5_Click()
Dim ip_all As String
'用Winsock 一句话得IP,可惜这样通常是内网的IP。
ip_all = Winsock1.LocalIP
ip_3 = Val(Left$(ip_all, 3))
'判断 IP是否在内网
If ip_3 = 192 Then
Text1.Text = Winsock1.LocalIP
End If
'/////////////// 获取用户名
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'/////////////// 访问注册表
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_SZ = 1
'/////////////// 自定义函数
'/////////////// 添加到注册表中的开机启动
Public Function AddToStarup(DesName As String, exePath As String) As Boolean
Dim SubKey As String
Dim hKey As Long
On Error GoTo acd
AddToStarup = False
SubKey = "Software\Microsoft\Windows\CurrentVersion\Run"
RegCreateKey HKEY_CURRENT_USER, SubKey, hKey
RegSetValueEx hKey, DesName, 0, REG_SZ, ByVal exePath, LenB(StrConv(exePath, vbFromUnicode)) + 1
RegCloseKey hKey
AddToStarup = True
Exit Function
acd:
AddToStarup = False
End Function
'/////////////// 右下角显示托盘图标+设置开机自动运行
Private Sub Check1_Click()
If Check1 Then '当选择框被选中时
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
'定义鼠标移动到托盘上时显示的Tip
.szTip = App.Title + "(版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide '添加到这里的代码,只要点击选择框,程序就会最小化到任务栏
Call AddToStarup("IP查看器", App.Path & "\IP查看器.exe") '这里是在系统启动时打开本程序
End If
End Sub
'/////////////// 设置剪贴板文本
Private Sub Command1_Click()
Clipboard.Clear
Clipboard.SetText Text1.Text '这里是复制text1的文本
End Sub
Private Sub Command2_Click()
Clipboard.Clear
Clipboard.SetText Text2.Text '这里是复制text2的文本
End Sub
Private Sub Command3_Click()
Clipboard.Clear
Clipboard.SetText Text3.Text '这里是复制text3的文本
End Sub
Private Sub Command4_Click()
Clipboard.Clear
Clipboard.SetText Text4.Text '这里是复制text4的文本
End Sub
'/////////////// 通过WinSocket控件获取本地IP地址
Private Sub Command5_Click()
Dim ip_all As String
'用Winsock 一句话得IP,可惜这样通常是内网的IP。
ip_all = Winsock1.LocalIP
ip_3 = Val(Left$(ip_all, 3))
'判断 IP是否在内网
If ip_3 = 192 Then
Text1.Text = Winsock1.LocalIP
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
出多少¥?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询