开心妙妙 发表于 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




ykfexcel 发表于 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

ykfexcel 发表于 2012-6-2 20:05

补充说明:
学习小组:G16
论坛ID: ykfexcel

szczm121 发表于 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退出窗体时总提示自动化出错,也就只好放弃了。

yl_li 发表于 2012-6-3 15:44

比想象中简单,不过课件也研究了不少时间。
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Static i
    i = UserForm1.Height
    If KeyCode = 27 Then Unload Me
    If KeyCode = 90 And Shift = 2 Then Me.Height = i + 10
    If KeyCode = 88 And Shift = 2 Then Me.Height = i - 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

yijundanny 发表于 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

gaoshuichang1 发表于 2012-6-3 17:02


Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) '按下键时
    If KeyCode = 27 Then
      Unload Me
    End If
    If KeyCode = 90 And Shift = 2 Then
      UserForm1.Height = 190
    End If
    If KeyCode = 88 And Shift = 2 Then
      UserForm1.Height = 170
    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

gaoshuichang1 发表于 2012-6-3 17:07

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) '按下键时
Dim k As Integer
    If KeyCode = 27 Then
      Unload Me
    End If
    If KeyCode = 90 And Shift = 2 Then
      Do While MsgBox("你还需要继续按CTRL+Z吗?", vbYesNo + vbQuestion, "提示") = vbYes
            k = k + 1
            UserForm1.Height = 180 + 10 * k
      Loop
    End If
    If KeyCode = 88 And Shift = 2 Then
      Do While MsgBox("你还需要继续按CTRL+X吗?", vbYesNo + vbQuestion, "提示") = vbYes
            k = k + 1
            UserForm1.Height = 180 - 10 * k
      Loop
    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

开心rabbit 发表于 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

byhdch 发表于 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 2 [3] 4
查看完整版本: 统计VBA学习小组正式组的积分帖之作业上交贴(第20周)