| MoveWindow |
|
|
| Private Declare Function MoveWindow Lib "user32" _ |
| (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, _ |
| ByVal nWidth As Long, ByVal nHeight As Long, _ |
| ByVal bRepaint As Long) As Long |
|
| Private Sub cmdExit_Click() |
|
| End Sub |
|
| Private Sub Form_Load() |
| Dim x% |
| With Combo1 |
| For x = 0 To 50 |
| .AddItem "String " & x |
| .AddItem "String " & x + 2 |
| Next x |
| End With |
| Combo1.ListIndex = 0 |
| Text1.Text = "150" |
| Text1.SelLength = Len(Text1.Text) |
| End Sub |
|
| Function SetDropDown(Yn&) |
| Dim y&, ys& |
| ys = Screen.Height / Screen.TwipsPerPixelY |
| If Yn > ys Then Yn = ys / 2 |
| With Combo1 |
| y = .Parent.ScaleMode |
| .Parent.ScaleMode = vbPixels |
| MoveWindow .hwnd, .Left, .Top, .Width, Yn, 1 |
| .Parent.ScaleMode = y |
| End With |
| End Function |
|
| Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) |
| If KeyCode = 13 Then '13 = Enter |
| If Text1.Text <> vbNullString Then |
| If Text1.Text < 100 Then Text1.Text = 100 |
| If Text1.Text > 800 Then Text1.Text = 800 |
| SetDropDown (Abs(CLng(Text1.Text))) |
| Me.Height = Combo1.Height + 400 |
| Text1.SelStart = 0 |
| Text1.SelLength = Len(Text1.Text) |
| End If |
| End If |
| End Sub |
|
| Private Sub Text1_KeyPress(KeyAscii As Integer) |
| Select Case Chr(KeyAscii) |
| Case "0" To "9" |
| Case Chr(vbKeyBack) |
| Case Else |
| KeyAscii = 0 |
| End Select |
| End Sub |
|