21.04.2014 Views

Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal ...

Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal ...

Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Private</strong> <strong>Sub</strong> <strong>UserForm</strong>_<strong>MouseUp</strong>(<strong>ByVal</strong> <strong>Button</strong> <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> Shift <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> X <strong>As</strong> Single, <strong>ByVal</strong> Y <strong>As</strong> Single)<br />

Select Case <strong>Button</strong><br />

Case vbKeyL<strong>Button</strong><br />

TextBox1.Text = "You pressed the left mouse button."<br />

Case vbKeyR<strong>Button</strong><br />

TextBox1.Text = "You pressed the right mouse button."<br />

End Select<br />

End <strong>Sub</strong>


<strong>Private</strong> <strong>Sub</strong> <strong>UserForm</strong>_MouseMove(<strong>ByVal</strong> <strong>Button</strong> <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> Shift <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> X <strong>As</strong> Single, <strong>ByVal</strong> Y <strong>As</strong> Single)<br />

Select Case <strong>Button</strong><br />

Case vbKeyL<strong>Button</strong><br />

TextBox1.Text = X<br />

Case vbKeyR<strong>Button</strong><br />

TextBox1.Text = Y<br />

End Select<br />

End <strong>Sub</strong>


<strong>Private</strong> <strong>Sub</strong> Image2_MouseMove(<strong>ByVal</strong> <strong>Button</strong> <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> Shift <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> X <strong>As</strong> Single, <strong>ByVal</strong> Y <strong>As</strong> Single)<br />

Select Case <strong>Button</strong><br />

Case vbKeyL<strong>Button</strong><br />

Image2.Move X, Y<br />

End Select<br />

End <strong>Sub</strong><br />

<strong>Private</strong> <strong>Sub</strong> Image3_MouseMove(<strong>ByVal</strong> <strong>Button</strong> <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> Shift <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> X <strong>As</strong> Single, <strong>ByVal</strong> Y <strong>As</strong> Single)<br />

Select Case <strong>Button</strong><br />

Case vbKeyL<strong>Button</strong><br />

Image3.Left = X + (0.5 * Image3.Width)<br />

Image3.Top = Y + (0.5 * Image3.Height)<br />

End Select<br />

End <strong>Sub</strong><br />

<strong>Private</strong> <strong>Sub</strong> <strong>UserForm</strong>_MouseDown(<strong>ByVal</strong> <strong>Button</strong> <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> Shift <strong>As</strong> <strong>Integer</strong>, <strong>ByVal</strong> X <strong>As</strong> Single, <strong>ByVal</strong> Y <strong>As</strong> Single)<br />

Select Case <strong>Button</strong><br />

Case vbKeyL<strong>Button</strong><br />

Image1.Move X, Y<br />

Case vbKeyR<strong>Button</strong><br />

Image2.Move X, Y<br />

End Select<br />

End <strong>Sub</strong>


Dim Day(1 To 7) <strong>As</strong> String<br />

<strong>Private</strong> <strong>Sub</strong> TextBox1_Change()<br />

If (TextBox1.Value > 0) And (TextBox1.Value < 8) Then<br />

Label1.Caption = Day(TextBox1.Value)<br />

Else<br />

Label1.Caption = "Enter an integer from 1 to 7"<br />

End If<br />

End <strong>Sub</strong><br />

<strong>Private</strong> <strong>Sub</strong> <strong>UserForm</strong>_Initialize()<br />

Day(1) = "Sunday"<br />

Day(2) = "Monday"<br />

Day(3) = "Tuesday"<br />

Day(4) = "Wednesday"<br />

Day(5) = "Thursday"<br />

Day(6) = "Friday"<br />

Day(7) = "Saturday"<br />

End <strong>Sub</strong>


Example of a Bubble Sort<br />

Dim Day(1 To 7) <strong>As</strong> String<br />

Dim HOLD <strong>As</strong> String<br />

Dim x <strong>As</strong> Single<br />

Dim y <strong>As</strong> Single<br />

<strong>Private</strong> <strong>Sub</strong> Command<strong>Button</strong>1_Click()<br />

For x = 1 To 7<br />

For y = 1 To 7 - x<br />

If Day(y + 1) < Day(y) Then<br />

HOLD = Day(y)<br />

Day(y) = Day(y + 1)<br />

Day(y + 1) = HOLD<br />

End If<br />

Next y<br />

Next x<br />

End <strong>Sub</strong><br />

<strong>Private</strong> <strong>Sub</strong> TextBox1_Change()<br />

If (TextBox1.Value > 0) And (TextBox1.Value < 8) Then<br />

Label1.Caption = Day(TextBox1.Value)<br />

Else<br />

Label1.Caption = "Enter an integer from 1 to 7"<br />

End If<br />

End <strong>Sub</strong><br />

<strong>Private</strong> <strong>Sub</strong> <strong>UserForm</strong>_Initialize()<br />

Day(1) = "Sunday"<br />

Day(2) = "Monday"<br />

Day(3) = "Tuesday"<br />

Day(4) = "Wednesday"<br />

Day(5) = "Thursday"<br />

Day(6) = "Friday"<br />

Day(7) = "Saturday"<br />

End <strong>Sub</strong>


Event<br />

AfterUpdate<br />

BeforeDragOver<br />

BeforeDropOrPaste<br />

BeforeUpdate<br />

Change<br />

Description<br />

Occurs after data in a control is changed through the user interface.<br />

Occurs when a drag-and-drop operation is in progress.<br />

Occurs when the user is about to drop or paste data onto an object.<br />

Occurs before data in a control is changed.<br />

Occurs when the Value property changes.<br />

DblClick Occurs when the user points to an object and then clicks a mouse button<br />

twice.<br />

Enter, Exit<br />

Error<br />

KeyDown, KeyUp<br />

KeyPress<br />

MouseDown, <strong>MouseUp</strong><br />

MouseMove<br />

Enter occurs before a control actually receives the focus from a control on<br />

the same HTML layout.Exit occurs immediately before a control loses the<br />

focus to another control on the same HTML layout.<br />

Occurs when a control detects an error and cannot return the error<br />

information to a calling program.<br />

Occur in sequence when a user presses and releases a key.KeyDown<br />

occurs when the user presses a key.KeyUp occurs when the user<br />

releases a key.<br />

Occurs when the user presses an ANSI key.<br />

Occur when the user clicks a mouse button.MouseDown occurs when the<br />

user presses the mouse button; <strong>MouseUp</strong> occurs when the user releases<br />

the mouse button.<br />

Occurs when the user moves the mouse.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!