Excel精英培训网

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

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

  [复制链接]
发表于 2012-6-2 19:34 | 显示全部楼层
本帖最后由 开心妙妙 于 2012-6-4 09:54 编辑

  • Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  •     If KeyCode = 90 And Shift = 2 Then
  •         Me.Height = Me.Height + 10
  •     ElseIf KeyCode = 88 And Shift = 2 Then
  •         Me.Height = Me.Height - 10
  •     ElseIf KeyCode = 27 Then
  •         Unload Me
  •     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


第16讲作业-窗体与控件-B08-开心妙妙.rar (14.58 KB, 下载次数: 2)

评分

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

查看全部评分

回复

使用道具 举报

发表于 2012-6-2 19:58 | 显示全部楼层
1题解:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
Unload Me
End If
End Sub

2题解:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim x As Integer
x = UserForm1.Height
If KeyCode = 90 And Shift = 2 Then
UserForm1.Height = x + 10
End If
End Sub

3题解:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim x As Integer
x = UserForm1.Height
If KeyCode = 88 And Shift = 2 Then
UserForm1.Height = x - 10
End If
End Sub

4题解:
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-6-2 20:05 | 显示全部楼层
补充说明:
学习小组:G16
论坛ID: ykfexcel
回复

使用道具 举报

发表于 2012-6-3 14:54 | 显示全部楼层
G17:SZCZM121交作业
Private Sub UserForm_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim A As Long
        A = Me.Height
    If KeyCode = 27 Then
    Unload Me
    ElseIf KeyCode = 90 And Shift = 2 Then
        A = A + 10
        Me.Height = A
    ElseIf KeyCode = 88 And Shift = 2 Then
        A = A - 10
        Me.Height = A
    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 Sub
本想把“Me.Height = A”放在END IF之后,这样一句就够了,可在测试用ESC退出窗体时总提示自动化出错,也就只好放弃了。

评分

参与人数 1金币 +8 收起 理由
兰色幻想 + 8 代码可以再完善

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 15:44 | 显示全部楼层
比想象中简单,不过课件也研究了不少时间。 窗体与控件2作业题.rar (14.02 KB, 下载次数: 2)

评分

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

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 16:10 | 显示全部楼层
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 27 Then
   Unload Me
ElseIf KeyCode = 90 And Shift = 2 Then
   Me.Height = Me.Height + 10
ElseIf KeyCode = 88 And Shift = 2 Then
   Me.Height = Me.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 Sub

评分

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

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 17:02 | 显示全部楼层
窗体与控件2作业题.rar (8.38 KB, 下载次数: 2)

评分

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

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 17:07 | 显示全部楼层
窗体与控件2作业题.zip (10.98 KB, 下载次数: 2)

评分

参与人数 1金币 +10 收起 理由
兰色幻想 + 10 还搞些花样

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 17:38 | 显示全部楼层
1. 按ESC键可以关闭窗体
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 27 Then
        Unload Me
    End If
End Sub
2. 按CTRL+Z 窗体的高度在原来的高度上+10(窗体的高度越来越高)
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If Shift = 2 And KeyCode = 90 Then
        Me.Height = Me.Height + 10
    End If
End Sub
3. 按CTRL+X 窗体的高度在原来的基础上-10
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If Shift = 2 And KeyCode = 88 Then
        Me.Height = Me.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 Button = 1 And Shift = 3 Then
        Unload Me
    End If
End Sub

评分

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

查看全部评分

回复

使用道具 举报

发表于 2012-6-3 21:24 | 显示全部楼层
A09:byhdch

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)   
    If KeyCode = 27 Then Unload 查询系统   
    If KeyCode = 90 And Shift = 2 Then
        Height = Height + 10
    ElseIf KeyCode = 88 And Shift = 2 Then
        Height = 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 查询系统  
End Sub

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-28 07:49 , Processed in 0.266419 second(s), 23 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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