DOC PREVIEW
Princeton COS 333 - Visual Basic

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Where do we go from here Visual Basic language development environment building GUI s scripting embedding viruses component based software libraries and software re use COM creating your own components other approaches to components CORBA RMI C and NET the next generation XML and related acronyms Visual Basic Windows graphics model similar to X Windows big library with graphics primitives at the bottom event loop graphical components but different in many respects not distributed not portable more complicated large library interface Visual Basic for building GUI s a language at about the same level as Java also usually interpreted controls analogous to Java Swing similar properties methods events interactive development environment draw the interface on the screen generally don t use layout managers code templates for binding actions to events create the code run debug within the environment 1 Why study use Visual Basic one of the most widely used languages systems very easy to start with very easy to do useful things http www cs princeton edu courses archive fallxx cs109 labs VB1 and VB2 easy access to Windows environment can do almost anything that can be done in Windows may not be fast may not scale up to big programs or big data embedded in other tools as extension mechanism Word Excel Powerpoint all contain VB can easily augment their capabilities scripting language for controlling other programs VBScript at the heart of a class of computer viruses Visual Basic components Visual Basic programming language modern dialect of Basic Basic created in 1964 by John Kemeny 47 49 and Tom Kurtz 56 reasonable control flow data types arrays structures a bit bulky verbose clumsy good error checking at compile and run time toolkit components standard library for math file I O text manipulation user interface components buttons text menus extensible access to Windows API and existing objects can add own C C code and create new controls glue language for assembling from pre built pieces integrated development environment interactive system for building and testing VB programs 1991 draw interface by dragging and dropping components fill in behaviors in code templates set properties like size color position manage edit source code and other resources run in controlled environment for testing and debugging compile and export as EXE file 2 Visual Basic language variables constants Boolean Integer Single Double String Const Dim s As String i As Integer d As Double Byte Date Currency Object Variant user defined arrays fixed size Dim ar 100 as Integer dynamic Dim dyn as Integer Redim dyn 10 declaration set size reset size preserve old contents Redim Preserve dyn 100 like realloc operators expressions And Or Not mod Types declarations conversions variables declared with Dim statement Dim i as Integer s as Single d as Double str as String Integer 32 bits Single Double approximately 6 or 15 digits with fractional part 3 14159 3 14159265358979323846 String any number of characters within quotes Object object in same sense as Java or C VB usually infers types from context does conversions automatically sometimes have to be explicit CInt string if can t tell from context that string is meant as a number CStr double to produce a string value Variant type holds any type 3 Control Flow If Then Else If i 0 Then print i is positive ElseIf i 0 Then print i is zero Else print i is negative End If For Next loop For i 1 To 10 print i i i 2 i Next i can go forward or backward any step size Do While loop i 1 Do While i 10 print i i i 2 i i i 1 Loop test at top or bottom use While or Until early exit with Exit Do Subroutines and functions Sub ask s As String Dim stat As String stat MsgBox Another game vbYesNo If stat vbYes Then End Sub Function Randint n As Integer As Integer Randint Int n Rnd 1 function name return value End Function call by reference by default ByVal to specify call by value Exit Sub and Exit Function for early exit 4 Standard VB libraries strings Len s Mid s p n InStr target pat s1 Like pat shell like pattern match math Sqr Rnd Sin Cos I O etc Open fin For Input As 1 Open fout For Output As 2 Do Until EOF 1 Line Input 1 textline Print 2 textline Loop Close 1 Close 2 run processes Call Shell command 1 Controls Interface components buttons sliders labels text boxes about 25 in basic set instances normally created at design time if in an array new ones can be added and deleted at run time menubar builder dialog controls each control has a fixed set of properties events and methods properties size position color caption name for what it is set when drawn usually or when program is running by assignments or functions in your program methods the operations it will do appropriate to what it is events external stimuli that it responds to mouse click typing scrolling size change window close when an event occurs VB calls the subroutine associated with it e g Button Click TextBox KeyPress etc what you write in the subroutine determines what the program does you define what the behavior is 5 Software re use how do we re use code that others have written If I have seen further than others it is because I have stood on the shoulders of giants source e g Open Source movement libraries e g lsocket on Unix DLL s on Windows Java packages classes C Standard Template Library Java Collection classes objects components Libraries linking to previously compiled code static linking all called routines are included in executable dynamic linking called routines located and linked in on demand shared libraries on Unix dynamic link libraries DLL s on Windows lots of advantages no cost if a particular routine is not called minor startup cost for initialization when called minimal cost when running extra indirection for call library code is shared among all simultaneous uses DLL s very much used in Windows some disadvantages DLL hell inconsistencies among versions especially after installation then uninstallation a single language solution more or less VB can call C C DLL s DLL runs in same address space protection issues not distributed 6 Extending VB by calling libraries can call any DLL from the Windows API can create and call your own DLL s COM Microsoft s component object model binary standard for creating using components components can be written in any language IDL interface definition language to describe arguments and return values generate necessary code components can be in same process separate process on same


View Full Document

Princeton COS 333 - Visual Basic

Download Visual Basic
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Visual Basic and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Visual Basic 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?