Download Visual basic intro and more Slides Computer Networks in PDF only on Docsity! Introduction To Visual Basic 6 Programming language Programming is writing instructions for a computer. Level of programming languages Machine language – 0s and 1s Intermediate languatge – assambly language. High level language – BASIC, C++… Why do we learn Visual Basic It shares the same principles with other programming languages. It is good when developing small and handy utility programs. It is supported by Microsoft. It is powerful when integrated with Excel and Word. Six Steps in Programming Problem Identification Solution Design Coding Compiling with compiler or running with interpreter Debugging Testing Step 1 and 2: Problem Identification and Design Identify what needs to be solved Make diagrams, and equations, etc Design: Analyze the problem and develop an ALGORITHM and FLOWCHART Step 4b: Interpreting Interpreting reads and runs one line of code each time. You can find “Grammar errors” in this stage. Advantage: Good for debugging Interpreter is easy to program. Disadvantage: Slow Interpreting and Compiling in VB
|s-ia- Boe | h = & Pst FS
Start With Eull Compile Ctrl+F5
|] Break Ctl+8reak
wi End
Restart shift
Step 5: Debugging Debugging is removing the “functional errors” from your program Running tells you where there are errors Go back to source code and fix errors Save and re-run Repeat until errors are gone VB programming Project Form 1 Form 2 Form 3 Text box Button Picture box Objects Text box Button Objects Definitions Form contains the Main Program Controls are user interface elements (text boxes, commands) in the Form Forms and Controls are referred to as OBJECTS Objects have PROPERTIES (features you can change) Forms in Visual Basic You create a form that is your graphical user interface Has places to input values Has buttons to click Has other user interface elements, e.g. Menu, scroll bar… Important Controls Text Boxes – area where you enter text Command Buttons – you click on them to do something Picture Boxes – Output your results. Text Boxes Properties: Name (of object) Text (the words) Alignment (left, right, middle) Appearance BackColor (background) BorderStyle Font FontColor Command Button Properties: Name BackColor Style (This controls the backcolor) Caption “Design time” and “Run time” When you design you can use the property window to set the property of certain object. When you run the program, you can only use code to change the property of that object. Just a Bunch of Objects Q: Now that you have a bunch of objects, how do you make them react to your command? A: Sub Procedures Sub Procedures are the instructions Sub Procedures go with Events (Like clicking a button) How the test program works
© ~
Ch rlsllo ores yo x]
Sub Procedure Two Objects: Text1 and Command1 Sub Procedure: Private Sub Command1_Click() Text1.FontSize = 18 End Sub When Command1 is clicked, the FontSize property of Text1 is changed to 18 Sub Procedure Private Sub CommButt_Click() Text1.FontSize = 18 Text1.BackColor = vbBlue Command1.Caption = "Get Some Now" End Sub Homework
O Read Chapters 1 & 2 in book