Your first VB program
This is your first Visual Basic program. This program demonstrates the use of 'print' method.![Your first VB program](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7KF4Rcb0Dnjg7h_1SH-DYei7SJ9suvF1sBp4j30vlDtjw4fIvVEH2mBX2E3tfSimBzobNQ1lC042ATFwpjqh5Acfh1gnOmGERz8a4kM655ADsFpe1jeHy4jA6KmS-RPQcgJEWCOXKI3s/s1600/First.jpg)
Code:
Private Sub Command1_Click()
Print "Welcome to www.vbtutes.com"
End Sub
Print "Welcome to www.vbtutes.com"
End Sub
Example of MouseMove
![MouseMove event Example of MouseMove event](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNxsLeGdr_3UNhnI6kGVy74Q0-890eReVY87vmqJbYTEmMhx3k9MlFTLhh-6dCAGdnXkqBSNv5pTYb9Ui6Obb1n_qY2lUUHCJz3_P1K02ccZfL2JV-qUpv_3e5zRoyi1s4Ij2NGJaIN-Y/s1600/MouseMove.jpg)
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
![MouseDown & MouseUp events sample program to show MouseDown & MouseUp events](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQQepiAaQiNZczWXsf-geayKxQWygvIozDvo0YzXTLbNWiaUD4qltmgEMpfRSaBgHkD77t520WwGO90EqVRJT0rHnkkN-wwY8l5vAwrmyZdOBTgDwpXIwZle5Ox0Eevjn2JeZ4REFgGvM/s1600/MouseDown&.jpg)
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
![General Declaration Variable declaration in general declaration section](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCfDm5ISygNNiF0HFfZz-5VWeLUl_KUibs4JfFxWnNqo6MIywgy8u5WuIWMKjVvKMeaVklk59XSXkXMr_P-qu0FdmRxI4Wwo6hfeczlG_qmGwwTzb5reaQ3q1JObXpydwLVSX_TbXFgoE/s1600/GeneralDeclaration.jpg)
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
![Clicks counter Clicks counter program uses static variable to display the number of clicks](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYeDi0uAVRCmnFde1BNGMSVWK72jCpP7KB8WBu109Y4V-IgBxM_drz4kHElz1aUIuabt9pU4s6e1nmJG807QaQUJrQ2sOV56PBs_u_mjk6cfWEdQTIOLXN6GIDdS5GnGEAY0MQVaCCcnQ/s1600/ClicksCounter.jpg)
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
![Displaying text The program shows message in text box](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizmMe_XgAlfa5eWYWl2Wrg8E815MR0NotlLkJL_9iW1srpm5SMIOoDlUL_xVMj1UuVWB8ar8Urm3tZf1DiUg48bHNhZs5vZJfeGOXHtyWamCcwlHgM40WVxIlMLQanbI-TPZV1Cgdasbc/s1600/Text+Display+program.jpg)
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
![Text Display 2 Displaying text with print method and textbox control](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiUYiNWCRufExB5YNc0SkkneeonfZvk5-5Xld3Mu81TPC82I4QzFHFLLBtiEryPOKvDn0gQ7Ta7aTtzf93trIR0V_5QeeITF67zWpalt6BU1rACDRrHz7ZfQMg9ROpp6ie1_OfDHKrt4U/s1600/Text+Display+2+program.jpg)
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
![Default and Cancel Default and Cancel property of form](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC0Wl8wE83uAsw66nH6onPJA6o0AEmErQH8kEeW0zybIGU3SOyha9_2G4Mj1Gp3hHH_pE_sM6A3B54-FqqaKXE0rJCuv-n-KA5n4N9zZKcFe2K1dy5lshDMh2cB6_107fFT09v-7qHrwg/s1600/Default+&+Cancel+key.jpg)
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![Set properties program The sample program showing how to set properties](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRVHWjmMnSDSdZFkkzr6t3DGvg1gr0A9REByLNelDZb9ln2B1RaZsJijZNNYMFnTCihcIu6J8L3gz3VSBmaLkbzSXpno_iPfZhDC5bEc8s15u-fPiFDKfHU8rvhdHHuccr5TwHbLMvW3g/s1600/SetProperties.jpg)
![Set properties program The sample program showing how to set properties](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRVHWjmMnSDSdZFkkzr6t3DGvg1gr0A9REByLNelDZb9ln2B1RaZsJijZNNYMFnTCihcIu6J8L3gz3VSBmaLkbzSXpno_iPfZhDC5bEc8s15u-fPiFDKfHU8rvhdHHuccr5TwHbLMvW3g/s1600/SetProperties.jpg)