Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!

[通知] 统计VBA学习小组正式组的积分帖之作业上交贴(第20周)

  [复制链接]
发表于 2012-5-31 22:09 | 显示全部楼层
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 90 And Shift = 2 Then
UserForm1.Height = UserForm1.Height + 10
ElseIf KeyCode = 88 And Shift = 2 Then
UserForm1.Height = UserForm1.Height - 10
End If
End Sub

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   If Button = 1 And Shift = 3 Then
    Unload Me
   End If
End Sub

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-5-31 23:03 | 显示全部楼层
  1. Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  2. Dim X
  3. X = Me.Height
  4. If KeyCode = 27 Then
  5. Unload Me
  6. ElseIf KeyCode = 90 And Shift = 2 Then
  7. Me.Height = X + 10
  8. ElseIf KeyCode = 88 And Shift = 2 Then
  9. Me.Height = X - 10
  10. End If
  11. ' MsgBox KeyCode
  12. End Sub

  13. Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  14. If Button = 1 And Shift = 3 Then
  15. Unload Me
  16. End If
  17. End Sub
复制代码

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-5-31 23:06 | 显示全部楼层
w2001pf 发表于 2012-5-30 14:29
作业在哪里啊?

http://www.excelpx.com/thread-245811-1-1.html
这是作业的链接。
回复

使用道具 举报

发表于 2012-6-1 01:17 | 显示全部楼层
'插入一个空白窗体,
'Print 要求:
'1 按ESC键可以关闭窗体
'2按CTRL+Z 窗体的高度在原来的高度上+10(窗体的高度越来越高)
'3按CTRL+X 窗体的高度在原来的基础上-10
'4按ctrl+shift键的同时左键单击窗体,可以把窗体关闭
'
'注: 上传答案时
'1 测试正确无误
'2 代码一定要贴出来可以不传附件
'3 在班里的指定作业贴处上交作业

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
'MsgBox KeyCode
    If KeyCode = 27 Then Unload Me
    If KeyCode = 90 And Shift = 2 Then Me.Height = Me.Height + 10
    If KeyCode = 88 And Shift = 2 Then Me.Height = Me.Height - 10


End Sub

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 1 And Shift = 3 Then Unload Me
End Sub


评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-1 20:59 | 显示全部楼层
 1、按ESC键可以关闭窗体
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then Unload Me
End Sub
2、按CTRL+Z 窗体的高度在原来的高度上+10(窗体的高度越来越高)
3、按CTRL+X 窗体的高度在原来的基础上-10
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 2 And KeyCode = 90 Then
    Height = Height + 10
ElseIf Shift = 2 And KeyCode = 88 Then
    Height = Height - 10
End If
End Sub
4、按ctrl+shift键的同时左键单击窗体,可以把窗体关闭
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Shift = 3 And Button = 1 Then Unload Me
End Sub

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 08:18 | 显示全部楼层
第16讲作业.rar (10.11 KB, 下载次数: 2)

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 08:36 | 显示全部楼层
[code]
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
  Me.Hide
  Else
If KeyCode = vbKeyZ And Shift = 2 Then
   Me.Height = Me.Height + 10
   Else
If KeyCode = vbKeyX And Shift = 2 Then
   Me.Height = Me.Height - 10
  End If
  End If
  End If
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  If Button = 1 And Shift = 3 Then
     Me.Hide
   End If
End Sub
[\:code]
H19:chenzhi_juan

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 17:05 | 显示全部楼层
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then

Unload UserForm1
End If

If KeyCode = 90 And Shift = 2 Then

UserForm1.Height = UserForm1.Height + 10

ElseIf KeyCode = 88 And Shift = 2 Then

UserForm1.Height = UserForm1.Height - 10

End If

End Sub

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 And Shift = 3 Then
Unload UserForm1
End If
End Sub

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 17:58 | 显示全部楼层
E学委:sunjing-zxl   交作业
代码中的"sunjing"是窗体名字

  1. 'esc=27,z=90,x=88
  2. 'shift 是按下shift(值为1) or ctrl(值为2)或alt(值为3)
  3. Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  4.     If KeyCode = 27 Then
  5.         Unload sunjing
  6.     ElseIf Shift = 2 Then
  7.         If KeyCode = 90 Then
  8.             sunjing.Height = sunjing.Height + 10
  9.         ElseIf KeyCode = 88 Then
  10.             sunjing.Height = sunjing.Height - 10
  11.         End If
  12.     End If
  13. End Sub
  14. ' button 值按左键返回1,按右键返回2,按中键返回4
  15. ' shift 按Shift返回1,按ctrl返回2,shift+ctrl返回3,Atl按回4
  16. ' X,Y 是指点击的位置
  17. Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  18.     If Button = 1 And Shift = 3 Then
  19.         Unload sunjing
  20.     End If
  21. End Sub
复制代码




评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 答案正确

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 18:33 | 显示全部楼层
16组:libenwen2011 (UID: 514207)

Private Sub UserForm_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)   If KeyCode = 27 Then 'ESC键关闭窗体
     Unload Me
  End If
     
  If KeyCode = 90 Then 'ctrl+Z窗体高度+10
     X = Me.Height
     Me.Height = X + 10
  End If

  If KeyCode = 88 Then 'ctrl+x窗体高度-10
     X = Me.Height
     Me.Height = X - 10
  End If
End Sub

'按下shift+ctrl组合键并且按鼠标左键,关闭窗体
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   If Button = 1 And Shift = 3 Then
      Unload Me
   End If
End Sub

评分

参与人数 1金币 +8 收起 理由
兰色幻想 + 8 答案正确

查看全部评分

回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-28 08:45 , Processed in 0.344357 second(s), 22 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表