Class 1.docx
- 文档编号:9820287
- 上传时间:2023-05-21
- 格式:DOCX
- 页数:48
- 大小:768.67KB
Class 1.docx
《Class 1.docx》由会员分享,可在线阅读,更多相关《Class 1.docx(48页珍藏版)》请在冰点文库上搜索。
Class1
LearnVisualBasic.NET
1.IntroductiontotheVisualBasic.NETEnvironment
Preview
∙Inthisfirstclass,wewilldoanoverviewofhowtobuildaWindowsapplicationusingVisualBasic.NET.You’lllearnanewvocabulary,anewapproachtoprogramming,andwaystomovearoundintheVisualBasic.NETenvironment.Oncefinished,youwillhavewrittenyourfirstVisualBasic.NETprogram.
CourseObjectives
∙UnderstandthebenefitsofusingMicrosoftVisualBasic.NETasanapplicationtool
∙UnderstandVisualBasic.NETevent-drivenprogrammingconcepts,object-orientedprogrammingterminology,andavailablecontrols
∙Learnthefundamentalsofdesigning,implementing,anddistributingaVisualBasic.NETWindowsapplication
∙LearntousetheVisualBasic.NETtoolbox
∙Learntomodifyobjectpropertiesanduseofobjectmethods
∙Usemenuandtoolbardesigntools
∙Learnhowtoreadandwritesequentialfiles
∙Understandproperdebugginganderror-handlingprocedures
∙Gainanunderstandingofgraphicmethodsandsimpleanimations
∙ObtainanintroductiontotheWindowsApplicationProgrammingInterface(API)formultimediaeffects
∙LearnhowtoprinttextandgraphicsfromaVisualBasic.NETapplication
∙GainskillstodevelopandimplementanHTML-basedhelpsystem
∙ObtainanintroductiontoimplementingVisualBasic.NETapplicationsontheinternetusingtheWebform
WhatisVisualBasic.NET?
∙VisualBasic.NETispartofagrandnewinitiativebyMicrosoft.Itisacompletere-engineeringofVisualBasicfortheMicrosoft.NETframework.WithVisualBasic.NET,youareabletoquicklybuildWindows-basedapplications(theemphasisinthiscourse),web-basedapplicationsand,eventually,softwareforotherdevices,suchaspalmcomputers.
∙WindowsapplicationsbuiltusingVisualBasic.NETfeatureaGraphicalUserInterface(GUI).Usersinteractwithasetofvisualtools(buttons,textboxes,toolbars,menuitems)tomakeanapplicationdoitsrequiredtasks.Theapplicationshaveafamiliarappearancetotheuser.AsyoudevelopasaVisualBasic.NETprogrammer,youwillbegintolookatWindowsapplicationsinadifferentlight.YouwillrecognizeandunderstandhowvariouselementsofWord,Excel,Accessandotherapplicationswork.YouwilldevelopanewvocabularytodescribetheelementsofWindowsapplications.
∙VisualBasic.NETWindowsapplicationsareevent-driven,meaningnothinghappensuntilanapplicationiscalledupontorespondtosomeevent(buttonpressing,menuselection,...).VisualBasic.NETisgovernedbyaneventprocessor.Asmentioned,nothinghappensuntilaneventisdetected.Onceaneventisdetected,acorrespondingeventprocedureislocatedandtheinstructionsprovidedbythatprocedureareexecuted.Thoseinstructionsaretheactualcodewrittenbytheprogrammer.InVisualBasic.NET,thatcodeiswrittenusingaversionoftheBASICprogramminglanguage.Onceaneventprocedureiscompleted,programcontrolisthenreturnedtotheeventprocessor.
Event
Procedures
AllWindowsapplicationsareevent-driven.Forexample,nothinghappensinWorduntilyouclickonabutton,selectamenuoption,ortypesometext.Eachoftheseactionsisanevent.
∙Theevent-drivennatureofapplicationsdevelopedwithVisualBasic.NETmakesitveryeasytoworkwith.AsyoudevelopaVisualBasic.NETapplication,eventprocedurescanbebuiltandtestedindividually,savingdevelopmenttime.And,ofteneventproceduresaresimilarintheircoding,allowingre-use(andlotsofcopyandpaste).
∙
SomeFeaturesofVisualBasic.NET
∙Allnew,easy-to-use,powerfulIntegratedDevelopmentEnvironment(IDE)
∙Fullsetofcontrols-you'draw'theapplication
∙Responsetomouseandkeyboardactions
∙Clipboardandprinteraccess
∙Fullarrayofmathematical,stringhandling,andgraphicsfunctions
∙Caneasilyworkwitharraysofvariablesandobjects
∙Sequentialfilesupport
∙Usefuldebuggerandstructurederror-handlingfacilities
∙Easy-to-usegraphictools
∙Powerfuldatabaseaccesstools(notcoveredinthiscourse)
∙AbilitytodevelopbothWindowsandinternetapplicationsusingsimilartechniques
∙Newcommonlanguageruntimemodulemakesdistributionofapplicationsasimpletask
VisualBasic.NETversusVisualBasic
∙Let’sgetsomethingstraightrightnow–VisualBasic.NETisnotanewversionofVisualBasic.VisualBasic.NETisanentirelynewproduct.IfyouarefamiliarwithVisualBasic,VisualBasic.NETwilllookfamiliar,buttherearemanydifferences.And,forthemostpart,thedifferencesarevastimprovementsoverVisualBasic.WhenyourealizethattheBASIClanguagehasnotundergonesubstantialchangesin20years,youshouldagreeitwastimeforaclean-upandimprovement.
∙AfewofthefeaturesofVisualBasic.NET,comparedtoVisualBasic:
∙NewIntegratedDevelopmentEnvironment
∙UsesObject-OrientedProgramming(OOP)methods
∙Newcontrolsandcontrolproperties
∙Redesignedcodewindow
∙Zero-basedarrays(noadjustablefirstdimension)
∙Easiertousecommondialogboxes
∙Structurederror-handling(nomoreOnErrorGoTo)
∙Newmenudesigntools
∙Newtechniquesforworkingwithsequentialfiles
∙Allnewgraphicsmethods
∙Newapproachestoprintingfromanapplication
∙Improvedsupporttoincorporatinghelpsystemsinapplications
∙Newwebformsforinternetapplications
∙ADO.NETfordatabaseaccess(notcoveredinthiscourse)
∙TouseVisualBasic.NET,you(andyourusers)mustbeusingWindows2000,WindowsXP,orWindowsNT.Asofnow,VisualBasic.NETapplicationswillnotrunonWindows9XorWindowsMemachines.
∙AppendixIofthesenotesisausefulreferenceforexperiencedVisualBasicprogrammers.InAppendixI,weprovideasynopsisonhowthematerialpresentedinthiscourseforVisualBasic.NETdiffersfromsimilarmaterialforVisualBasic.Thematerialisorganizedaccordingtothe10chapters(classes)providedinthesenotes.AlsoprovidedinAppendixIisadiscussiononmigratingexistingVisualBasicapplicationstoVisualBasic.NET.
ABriefLookatObject-OrientedProgramming(OOP)
∙SinceVisualBasicwasfirstintroducedintheearly1990’s,amajorcriticismfrommanyprogrammers(especiallythoseusingCandC++)wasthatitwasnotatrueobject-orientedlanguage.And,withthatlimitation,manydismissedVisualBasicasa“toy”language.Thatlimitationnolongerexists!
∙VisualBasic.NETisfullyobject-oriented.Forthisparticularcourse,wedon’thavetoworrymuchaboutjustwhatthatmeans(manysizeabletomeshavebeenwrittenaboutOOP).Whatweneedtoknowisthateachapplicationwewritewillbemadeupofobjects.Justwhatisanobject?
Itcanbemanythings:
avariable,afont,agraphicsregion,arectangle,aprinteddocument.Thekeythingtorememberisthattheseobjectsrepresentreusableentitiesthatareusedtodevelopanapplication.This‘reusability’makesourjobmucheasierasaprogrammer.
∙InVisualBasic.NET,therearethreetermsweneedtobefamiliarwithinworkingwithobject-orientedprogramming:
Namespace,ClassandObject.Objectsarewhatareusedtobuildourapplication.Wewilllearnaboutmanyobjectsthroughoutthiscourse.Objectsarederivedfromclasses.Thinkofclassesasgeneraldescriptionsofobjects,whicharethenspecificimplementationsofaclass.Forexample,aclasscouldbeageneraldescriptionofacar,whereanobjectfromthatclasswouldbeaspecificcar,sayared1965FordMustangconvertible(aniceobject!
).Lastly,anamespaceisagroupingofdifferentclassesusedinthe.NETworld.Onenamespacemighthavegraphicsclasses,whileanotherwouldhavemathfunctions.Wewillseeseveralnamespacesinourwork.
∙Forthiscourse,ifyouremembernamespace,classandobject,youhavesufficientOOPknowledgetobuildapplications.Theprimaryuseforthesetermsiswhensearchingforhelponaparticulartopic.Whenseekinghelp,youneedtoknowthatanobjectcomesfromaclasswhichcomesfromanamespaceOnceyoucompletethiscourse,youcanfurtherdelveintotheworldofOOP.Then,you’llbeabletothrowaroundtermslikeinheritance,polymorphism,overloading,encapsulation,andoverriding.
∙Thebiggestadvantageoftheobject-orientednatureofVisualBasic.NETisthatitisnolongera“toy”language.Infact,VisualBasic.NETusesthesameplatformfordevelopmentanddeployment(incorporatingthenewCommonLanguageRuntime(CLR)module)asthemoreesotericlanguages(VisualC++andthenewVisualC#).Becauseofthis,thereshouldbenoperformancedifferencesbetweenapplicationswritteninVisualBasic.NET,VisualC++.NET,orVisualC#.NET!
StructureofaVisualBasic.NETWindowsApplication
∙WewanttogetstartedbuildingourfirstVisualBasic.NETWindowsapplication.But,firstweneedtodefinesomeoftheterminologywewillbeusing.InVisualBasic.NET,aWindowsapplicationisdefinedasasolution.Asolutionismadeupofoneormoreprojects.Projectsaregroupsofformsandcodethatmakeupsomeapplication.Inmostofourworkinthiscourse,ourapplications(solutions)willbemadeupofasingleproject.Becauseofthis,wewillusuallyusethetermsapplication,solutionandprojectsynonymously.
∙Asmentioned,aproject(application)ismadeupofformsandcode.Pictorially,thisis:
Project
Application(Project)ismadeupof:
ØForms-Windowsthatyoucreateforuserinterface
ØControls-Graphicalfeaturesdrawnonformstoallowuserinteraction(textboxes,labels,scrollbars,buttons,etc.)(FormsandControlsareobjects.)
ØProperties-Everycharacteristicofaformorcontrol
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Class