整人VB小程序.doc

上传人:hw****26 文档编号:3529197 上传时间:2019-06-02 格式:DOC 页数:2 大小:24KB
下载 相关 举报
整人VB小程序.doc_第1页
第1页 / 共2页
整人VB小程序.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、整人 VB 小程序:倒计时关机程序启动,会进入倒计时关机状态。除非用户输入特定字符(如:我是大傻瓜),否则程序不会结束。 以下代码在 VB6 调试通过。首先,在窗体放置 6 个控件,不需设置任何属性: Label1、Label2、Label3、Command1、Text1、Timer1需修改 * 处的关机倒计时时间 和 要求用户输入的字符Private Declare Function ExitWindowsEx Lib “user32“ (ByVal uFlags As Long, ByVal dwReserved As Long) As LongConst EWX_SHUTDOWN = 1

2、Dim nJiShi As String, nOK As BooleanPrivate Declare Function SetWindowPos Lib “user32“ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Const HWND_Top = 0 hWndInsertAfter 参数:Z 序列的顶部Private C

3、onst HWND_TopMost = -1 最上Private Const SWP_NoSize = &H1 wFlags 参数Private Const SWP_NoMove = &H2Private Const SWP_NoZorder = &H4Private Const SWP_ShowWindow = &H40Private Const SWP_HideWindow = &H80Private Sub Form_Load()Dim SnJiShi = “0:10:05“ * 设置关机时间,可修改Label1.AutoSize = True: Label1.Caption = “请输

4、入正确字符,否则自动关机。你是什么人?“Label2.AutoSize = True: Label2.Caption = “Label3.AutoSize = True: Label3.Caption = “: Label3.ForeColor = 255Timer1.Enabled = True: Timer1.Interval = 1000Me.Caption = “自动关机“Text1.Text = “: Command1.Caption = “确定(&Y)“S = Label1.HeightLabel2.Move S, S: Label1.Move S, S * 2.5Text1.Mo

5、ve S, S * 4, S * 10, S: Label3.Move S, S * 7Command1.Move S * 8, S * 6, S * 5, S * 2End SubPrivate Sub Command1_Click()If Text1.Text =“我是大傻瓜 “ or Text1.Text =“我是大笨蛋“ Then * 要求用户输入的字符MsgBox “回答正确:你是大笨蛋!“, vbInformation, “回答问题“nOK = True: Unload MeElseIf Trim(Text1.Text) = “ ThenLabel3.Caption = “请回答问

6、题“ElseLabel3.Caption = “回答错误“End IfEnd IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)If Not nOK Then Cancel = 1End SubPrivate Sub Timer1_Timer()Dim nTime As String, S As LongCall WinInTop(Me.hwnd) 使本程序显示在最前面nJiShi = DateAdd(“s“, -1, nJiShi)Label2.Caption = “关机到计时:“ & nJiShiS = Format(nJiShi, “hhmmss“)If S 0 Then Exit SubExitWindowsEx EWX_SHUTDOWN, 0nOK = TrueEnd SubPrivate Sub WinInTop(hwnd As Long)Dim wAfter As Long, wFlags As LongwAfter = HWND_TopMostwFlags = SWP_NoSize + SWP_NoMoveSetWindowPos hwnd, wAfter, 0, 0, 0, 0, wFlagsEnd Sub

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。