1 / 18

VISUAL BASIC

VISUAL BASIC. Lecture #4 WORKING WITH FRAMES. By Shahid Naseem (Lecturer). LECTURE OUTLINES. LECTURE OUTLINES. Event of command buttons Uses of Command buttons List box controls Programs. BOOKS AVAILABLE IN MARKET. C Programming using Turbo C++ Schaum Series

vartan
Télécharger la présentation

VISUAL BASIC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VISUAL BASIC Lecture #4 WORKING WITH FRAMES By ShahidNaseem (Lecturer)

  2. LECTURE OUTLINES

  3. LECTURE OUTLINES • Event of command buttons • Uses of Command buttons • List box controls • Programs Introduction of Visual Basic (Civil Engineering Department)

  4. BOOKS AVAILABLE IN MARKET • C Programming using Turbo C++ Schaum Series • Introduction to Computer 7thedition Peter Norton • How to Programming with C++ 8th Edition Deitel & Deitel • Visual Basic 2005 EvangelosPetroutsos Introduction of Visual Basic (Civil Engineering Department)

  5. DEBUGGING • The errors in the program are called bugs. The process to detect and to remove errors in the program is called debugging. • Syntax errors • Run time errors • Logical errors Syntax errors • The rules for writing the computer programs in a programming language is known as syntax of the language. • The syntax errors occurred when the syntax of the programming language are not followed. • The syntax errors are easy to locate and remove. Introduction of Visual Basic (Civil Engineering Department)

  6. DEBUGGING e.g. Private sub command1 _click (() For 1,10 End sub Message Compile error Expected: to Run time errors • The errors that are occur during the execution of program are called the run time errors. • If input data given to the program is not correct. • If hardware problem occurs such as hard disk error. Introduction of Visual Basic (Civil Engineering Department)

  7. WORKING WITH FORM • Event of Form • Load: when form is loaded in the memory • Unload: when form is unloaded from the memory. • Activate: When form is on the screen • Deactivate: When form is Off from the screen • Resize: When form is resized. • Methods of form: • The show method • The hide method • The print form method • The unload statement. Introduction of Visual Basic (Civil Engineering Department)

  8. PROGRAM#4 • Develop an application program having form with no GUI control. It should perform the following actions when user interacts with form. • The form appears maximized when program is run. • Set background color appears as “red” when mouse is single clicked on the form and background color is changed to “green” when mouse is double clicked on the form. Form1CaptionForm testing program Window state 2-maximized Introduction of Visual Basic (Civil Engineering Department)

  9. PROGRAM#4 Private Sub Form_Click() Form1.BackColor = vbRed End Sub Introduction of Visual Basic (Civil Engineering Department)

  10. PROGRAM#4 • Private Sub Form_DblClick() • Form1.BackColor = vbGreen • End Sub Introduction of Visual Basic (Civil Engineering Department)

  11. EVENT OF COMMAND BUTTONS Click: • The click event is the primary and commonly used event of command button. • It is triggered when: • Command button is singled clicked. • Command button has the focus and the enter key or spacebar key is pressed. • Command button access key is pressed. Dbl Click: • This event of command button is triggered when mouse is double clicked on button. Mouse Click: • This event of command button is triggered when mouse pointer is moved over the button. Got Focus: • This event of command button is triggered when it gets focus. Lost Focus: • This event of command button is triggered when it loses focus. Introduction of Visual Basic (Civil Engineering Department)

  12. PROGRAM#5 Introduction of Visual Basic (Civil Engineering Department)

  13. PROGRAM#5 Form1 Caption Command Button Application Command1 Caption First Button Style Graphical Command2 Caption Second Button Style Graphical Command3 Caption Third Button Style Graphical Private Sub Command1_Click() Form1.BackColor = vbRed Command1.BackColor = vbGreen Command2.BackColor = vbYellow Command3.BackColor = vbBlue End Sub Introduction of Visual Basic (Civil Engineering Department)

  14. PROGRAM#6 Develop an application program to perform simple arithmetic operations by two numbers. Form1 Caption Arithmetic Operations Label1 Caption Enter First Number Label2 Caption Enter Second Number Label3 blank Text1 blank Text2 blank Command1 Caption Operation Introduction of Visual Basic (Civil Engineering Department)

  15. PROGRAM#6 Private Sub Command1_Click() Label3.Caption = Val(Text1.Text) + Val(Text2.Text) End Sub Introduction of Visual Basic (Civil Engineering Department)

  16. LIST BOX CONTROL The list box control is used to display a long list of items. Properties Events List List count List Index Click Mouse Select Dbl Click Style Selected Select Count Sorted Index Text Introduction of Visual Basic (Civil Engineering Department)

  17. PROGRAM#7 Develop an application program to add and delete items to and from the list at runtime as • Type the text box and click add button to add the item to list box. • Select the item from list and click delete button to delete the selected item. Introduction of Visual Basic (Civil Engineering Department)

  18. PROGRAM#7 Private Sub Command1_Click() List1.AddItem Text1.Text Text1.Text = "" End Sub Private Sub Command2_Click() List1.RemoveItem (List1.ListIndex) End Sub Introduction of Visual Basic (Civil Engineering Department)

More Related