快捷导航 上传作品

[VB] vb全局判断

[复制链接]
梅雷工具箱发表于 2015-6-25 13:47:13 | 显示全部楼层 |阅读模式
vb全局判断
'全局判断用的是时间控件

====================================================

'全局判断 文件是否存在
Private Sub Form_Load()
Timer1.Interval = 100: Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
'【判断文件是否存在】
If Dir("c:\新建 文本文档.txt") <> "" Then
Text1 = "存在"
Else
Text1 = "不存在"
End If
End Sub

=======================================================

'全局判断鼠标的单击情况
'声明(鼠标有关)
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

'时间控件的设置
Private Sub Form_Load()
  Timer1.Interval = 100: Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
  If GetAsyncKeyState(vbLeftButton) < 0 And GetAsyncKeyState(vbRightButton) < 0 Then '按下鼠标左键
  Me.Caption = "您同时按下了鼠标左右键"
  ElseIf GetAsyncKeyState(vbLeftButton) < 0 Then '按下左键
  Me.Caption = "您点击了鼠标左键"
  ElseIf GetAsyncKeyState(vbRightButton) < 0 Then '按下右键
  Me.Caption = "您点击了鼠标右键"
  End If
  If GetAsyncKeyState(vbMiddleButton) < 0 Then  '按下鼠标中键
  Me.Caption = "您点击了鼠标中键"
  End If
End Sub


_____________________________________________________________________________ _

中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/
就上UG网淘宝直营店
回复

使用道具 评分 举报

您需要登录后才可以回帖 登录 | 注册UG网

本版积分规则