Your first VB program
This is your first Visual Basic program. This program demonstrates the use of 'print' method.
Code:
Private Sub Command1_Click()
Print "Welcome to www.vbtutes.com"
End Sub
Print "Welcome to www.vbtutes.com"
End Sub
Example of MouseMove

Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.Height = Form1.Height + 5
Form1.Width = Form1.Width + 5
End Sub
Form1.Height = Form1.Height + 5
Form1.Width = Form1.Width + 5
End Sub
Example of MouseDown & MouseUp

Code:
Private Sub cmdClear_Click()
Text1.Text = ""
End Sub
_________________________________________________________________
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = ""
Text1.Text = "MouseDown event"
End Sub
_________________________________________________________________
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = ""
Text1.Text = "MouseUp event"
End Sub
Text1.Text = ""
End Sub
_________________________________________________________________
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = ""
Text1.Text = "MouseDown event"
End Sub
_________________________________________________________________
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = ""
Text1.Text = "MouseUp event"
End Sub
_______________________________________________________________
General Declaration

Code:
'Declarations section
Dim n As Integer 'n is accessible from all the procedures
________________________________________________________________
Private Sub cmdShow1_Click()
n = 7
Print n
End Sub
________________________________________________________________
Private Sub cmdShow2_Click()
Print n + 1
End Sub
Dim n As Integer 'n is accessible from all the procedures
________________________________________________________________
Private Sub cmdShow1_Click()
n = 7
Print n
End Sub
________________________________________________________________
Private Sub cmdShow2_Click()
Print n + 1
End Sub
Clicks Counter

Code:
Private Sub cmdClick_Click()
Static n As Integer
n = n + 1
Print n
End Sub
Static n As Integer
n = n + 1
Print n
End Sub
Text Dispay 1

Code:
Private Sub cmdShow_Click()
txtField.Text = "Hello World"
End Sub
__________________________________
Private Sub cmdExit_Click()
End
End Sub
__________________________________
Private Sub cmdClear_Click()
txtField.Text = ""
End Sub
txtField.Text = "Hello World"
End Sub
__________________________________
Private Sub cmdExit_Click()
End
End Sub
__________________________________
Private Sub cmdClear_Click()
txtField.Text = ""
End Sub
_____________________________________________________________
Text Display 2

Code:
Private Sub cmdPrint_Click()
Dim s As String
s = txtField.Text
Print s
End Sub
________________________________
Private Sub cmdClear_Click()
Cls 'Form1.Cls is also correct
End Sub
Dim s As String
s = txtField.Text
Print s
End Sub
________________________________
Private Sub cmdClear_Click()
Cls 'Form1.Cls is also correct
End Sub
_________________________________________________________
Default & Cancel key

Code:
Private Sub cmdShow_Click()
MsgBox "You have pressed the default button !", vbInformation, ""
End Sub
_________________________________________
Private Sub cmdExit_Click()
End
End Sub
MsgBox "You have pressed the default button !", vbInformation, ""
End Sub
_________________________________________
Private Sub cmdExit_Click()
End
End Sub
Set properties
