1、1这个是关闭桌面所有窗口 (直接复制上去就 ok) Private Type POINTAPI x As Long y As Long End Type Private Declare Function GetCursorPos Lib “user32“ (lpPoint As POINTAPI) As Long Private Declare Function WindowFromPoint Lib “user32“ (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function ShowWindow
2、 Lib “user32“ (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Dim a(50) As Long Dim I As Integer Dim flag As Boolean Private Sub Command1_Click() flag = True MsgBox “都叫你别冲动了.重启吧“ End End Sub Private Sub Form_Load() I = 0 flag = fase End Sub Private Sub Form_QueryUnload(Cancel As Integer, Unload
3、Mode As Integer) Text1 = “小鹏提醒你,别激动.!“ Cancel = True End Sub Private Sub Timer1_Timer() Dim lg As Long 2On Error Resume Next Dim curhWnd As Long Current hWnd Dim lp As POINTAPI If flag = False Then Exit Sub I = I + 1 If I 0 Then h2 = GetDlgItem(h1, &H130) If h2 0 :当返回值非零时继续获取下一个进程 exename = proc.szE
4、xeFile If Left(LCase(exename), 6) = “qq.exe“ Then hand = OpenProcess(PROCESS_TERMINATE, True, proc.th32ProcessID) :获取进程句柄 TerminateProcess hand, 0 :关闭进程 End If theloop = ProcessNext(snap, proc) Wend CloseHandle snap :关闭进程“快照”句柄 MsgBox “真遗憾,您扣扣掉线了!“ End End Sub这个是爱不爱我代码,挺好玩的这个 (需要添加两个 command) Option
5、 Explicit Private Sub Command1_GotFocus() Command2.SetFocus End Sub Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Randomize Timer With Me Command1.Move Rnd * (.ScaleWidth - Command1.Width), Rnd * (.ScaleHeight -Command1.Height) End With End Sub Private
6、 Sub Command2_Click() MsgBox “我也爱你!“ End End Sub Private Sub Form_Load() 7Me.AutoRedraw = True Me.FontSize = 30 Me.Print “你爱不爱我?“ Command1.Caption = “不爱 “ Command2.Caption = “爱“ End Sub Private Sub Form_Unload(Cancel As Integer) Cancel = 1 End Sub繁体简体转换 (需要添加 4 个 Cammand.1 个 text) Private Declare Fu
7、nction LCMapString Lib “kernel32“ Alias “LCMapStringA“ (ByValLocale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long Private Declare Function lstrlen Lib “kernel32“ Alias “lstrlenA“ (ByVal lpString As String)
8、 As Long 简转繁 Public Function JToF(ByVal Str As String) As String Dim STlen As Long Dim STf As String STlen = lstrlen(Str) STf = Space(STlen) LCMapString &H804, &H4000000, Str, STlen, STf, STlen JToF = STf End Function 繁转简 Public Function FToJ(ByVal Str As String) As String Dim STlen As Long 8Dim STj
9、 As String STlen = lstrlen(Str) STj = Space(STlen) LCMapString &H804, &H2000000, Str, STlen, STj, STlen FToJ = STj End Function Private Sub Command1_Click() Text1.Text = JToF(Text1.Text) End Sub Private Sub Command2_Click() Text1.Text = FToJ(Text1.Text) End Sub Private Sub Command3_Click() Text1.Tex
10、t = “ End Sub Private Sub Command4_Click() End End Sub打开我的电脑等 (需要添加 5 个 Command) Private Declare Function ShellExecute Lib “shell32.dll“ Alias “ShellExecuteA“ (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nS
11、howCmd As Long) As Long Const SW_SHOWNORMAL = 1 Private Sub Command1_Click(Index As Integer) Select Case Index Case 0 我的文档 ShellExecute Me.hwnd, “open“, “explorer“, vbNullString, vbNullString, 1 Case 1 我的电脑 9ShellExecute Me.hwnd, “open“, “explorer“, “:20D04FE0-3AEA-1069-A2D8-08002B30309D“, vbnulstri
12、ng, 1 Case 2 网上邻居 ShellExecute Me.hwnd, “open“, “explorer“, “:208d2c60-3aea-1069-a2d7-08002b30309d“, vbNullString, 1 Case 3 回收站 ShellExecute Me.hwnd, “open“, “explorer“, “:645ff040-5081-101b-9f08-00aa002f954e“, vbNullString, 1 Case 4 控制面板 ShellExecute Me.hwnd, “open“, “explorer“, “:21ec2020-3aea-106
13、9-a2dd-08002b30309d“, vbNullString, 1 End Select End Sub五个窗口:分别代表任意自然数 a ,b ,c ,d,x, 一个命令按钮 要求在前四个窗口中输入任意自然数,然后点击“运算按钮” 程序自动输出加减乘除的运算结果到第五个窗口中! 用 VB 如何实现如下算式? x = ((a + b) / 3 + (c + d) / 2) 比如:a=3 b=6 c=4 d=8 则点击运算按钮后得到计算结果: x=9 程序图如下2 楼上面的图片中多了两个方框 f,g ,呵呵,抱歉啊 最近刚学 VB,编的上面的程序运行 ,如下: x =(a + b)/3 +
14、(c + d)/2 = (3 + 6) / 3 + (4 + 8) / 2 10=36 / 2 + 48 /2 =18 + 24 =42 计算老是把“+”当连接符,导致出错,郁闷死了117.32.153.* 3 楼晕,写错了,应该是这样: x =(a + b)/3 +(c + d)/2 = (3 + 6) / 3 + (4 + 8) / 2 =36 / 3 + 48 /2 =12 + 24 =364 楼应该先定义变量类型 加上如下代码即可: Private Sub Command1_Click() dim a%,b%,c%,d%,x% 定义变量 a=val(text1.text)用 val()
15、函数将字符串变量转换为整形变量 b=val(text2.text) c=val(text3.text) d=val(text4.text) x=(a+b)/3+(c+d)/2计算 x 的值 text5.text=cstr(x)转换类型,输出 x End Sub说明:1.共有 4 个文本框其,其中三个是填入或输出数据的(名称分别是:txta txtb txtc) ,剩下的那个是符号(txtd)2.共 7 个按钮,4 个是符号按钮,一个计算,一个清零这是我弄的程序”袖珍计算器” 代码也是自己编写的,代码如下:通用声明 Dim j As Integer 定义 j 为整型 Private Sub Text1_Change()End SubPrivate Sub Command1_Click() txtfuhao.Text = “+“ 将”显示到文本框 txtfuhao.Text 中 End SubPrivate Sub Command2_Click()
Copyright © 2018-2021 Wenke99.com All rights reserved
工信部备案号:浙ICP备20026746号-2
公安局备案号:浙公网安备33038302330469号
本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。