VB6 demo applications


Example of LostFocus

The Example of LostFocus program shows which CommandButton among two has lost the focus. The MsgBox function shows it.



             
                                                   >> DOWNLOAD
Code:
Private Sub cmd_LostFocus()
    MsgBox "Command1 has lost the focus"
End Sub
______________________________________________________________





ASCII Converter

The ASCII Converter program converts from ASCII to Character and from Character to ASCII. This program demonstrates the Change and KeyPress event.


Learn about events:  

The ASC function
             
                                                   >> DOWNLOAD
Code:
Private Sub cmdChange_Click()
    Text1.SetFocus

    If Label1.Caption = "Character" Then
        Label1.Caption = "ASCII"
        Label2.Caption = "Character"
    Else
        Label1.Caption = "Character"
        Label2.Caption = "ASCII"
    End If

    Text1.Text = ""
    Text2.Text = ""
End Sub
________________________________________________
Private Sub Text1_Change()
    If Label1.Caption = "ASCII" Then
        Text2.Text = Chr(Val(Text1.Text))
    End If
End Sub
________________________________________________
Private Sub Text1_KeyPress(KeyAscii As Integer)
    If Label1.Caption = "Character" Then
        Text2.Text = KeyAscii
        Text1.Text = ""
    End If
End Sub
________________________________________________________________
 



Make Shortcut Key 1

This is a very easy program that teaches you how to make shortcut key in visual basic. The program enables you to clear a TextBox pressing F5 key.


Learn more here: 

Learning keydown event
             
                                                   >> DOWNLOAD
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF5 Then
        Text1.Text = ""
    End If
End Sub
__________________________________________________



Make Shortcut Key 2


The Make Shortcut key 2 sample program that uses the KeyDown event procedure allows you to change the form's background color pressing some shortcut keys.


Learn about common events:  

             
                                                   >> DOWNLOAD
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyG And Shift = vbCtrlMask Then
        Form1.BackColor = vbGreen
    ElseIf KeyCode = vbKeyD And Shift = vbShiftMask Then
        Form1.BackColor = &HE0E0E0
    End If
End Sub
______________________________________________________________





Mouse Capture

The Mouse Capture sample application shows the x,y coordinates of the mouse pointer while you move the mouse on the form and shows which mouse button has been pressed.


Learn about mouse events:  

Learning the mousedown event
             
                                                   >> DOWNLOAD
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button And vbLeftButton Then
        lblMouseButton.Caption = "Left"
    ElseIf Button And vbRightButton Then
        lblMouseButton = "Right"
    ElseIf Button And vbMiddleButton Then
        lblMouseButton = "Middle"
    End If

    lblX.Caption = X
    lblY.Caption = Y

End Sub
________________________________________________
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    lblX.Caption = X
    lblY.Caption = Y
End Sub
_____________________________________________________________



Mouse Hover

The Mouse Hover application shows how to  implement mouse hover effects in your program. Though Visual Basic 6.0 does not provide the Mouse Hover event, you can still achieve the hover effects writing some lines of code.


Learn more:  

             
                                                   >> DOWNLOAD
Code:
Private Sub cmdClickMe_Click()
    txtMsg.Text = "Welcome to VbTutes.com !"
End Sub
________________________________________________
Private Sub cmdClickMe_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Shape1.Visible = True
    cmdClickMe.FontSize = 17
    cmdClickMe.BackColor = vbGreen

End Sub
________________________________________________
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Shape1.Visible = False
    cmdClickMe.FontSize = 10
    cmdClickMe.BackColor = &H8000000F
End Sub
________________________________________________________________



I-Card

The I-Card program makes a student I-Card. It uses the Line and Shape control. This program shows how to enhance the graphical interface using these controls.


Learn about line and shape:  

Line and Shape
             
                                                   >> DOWNLOAD
_________________________________________________



Move Example 

This example program teaches you about the Move method. The program uses the Move method to move Label controls on the Form from one position to another.


Learn about methods:  

Move method
             
                                                   >> DOWNLOAD
Code:
Private Sub cmdMoveToRight_Click()
    Label1.Move 3000
End Sub
________________________________________________
Private Sub cmdMoveUpwards_Click()
    Label2.Move 1200, 1000
End Sub
________________________________________________
Private Sub cmdReset_Click()
    Label1.Left = 1440
    Label2.Top = 2040

    Label3.Left = 2160
    Label3.Top = 3960
    Label3.Width = 1935
    Label3.Height = 1095
End Sub
________________________________________________
Private Sub cmdTopRightCorner_Click()
    Label3.Move 6500, 240, 1000, 500
End Sub