外文翻译--准备将 Visual Basic 6.0 应用程序升级到 Visual Basic.NET.doc
英文资料-1-PreparingYourVisualBasic6.0ApplicationsfortheUpgradetoVisualBasic.NETOverviewThisdocumentprovidesrecommendationsfordevelopersusingMicrosoft®VisualBasic®whoareplanningtoupgradetheirapplicationstoMicrosoftVisualBasic.NET.VisualBasic.NETwillopenandupgradeVisualBasic6.0projectstoVisualBasic.NETtechnologies,butinmostcasesyouwillneedtomakesomemodificationstoyourprojectsafterbringingthemintoVisualBasic.NET.ThepurposeofthisdocumentistorecommendhowtodesignandimplementyourcurrentVisualBasicprojectstominimizethenumberofchangesyouwillneedtomakewhentheyareupgradedtoVisualBasic.NET.Whereappropriate,weusenewlanguageconstructs;however,thisdocumentisnotintendedtobeaVisualBasic.NETlanguagereference.WhatIsVisualBasic.NET?VisualBasic.NETisthenextversionofVisualBasic.RatherthansimplyaddingsomenewfeaturestoVisualBasic6.0,MicrosofthasreengineeredtheproducttomakeiteasierthaneverbeforetowritedistributedapplicationssuchasWebandenterprisen-tiersystems.VisualBasic.NEThastwonewformspackages(WindowsFormsandWebForms);anewversionofADOforaccessingdisconnecteddatasources;andstreamlinedlanguage,removinglegacykeywords,improvingtypesafety,andexposinglow-levelconstructsthatadvanceddevelopersrequire.ThesenewfeaturesopennewdoorsfortheVisualBasicdeveloper:WithWebFormsandADO.NET,youcannowrapidlydevelopscalableWebsites;withinheritance,thelanguagenowtrulysupportsobject-orientedprogramming;WindowsFormsnativelysupportsaccessibilityandvisualinheritance;anddeployingyourapplicationsisnowassimpleascopyingyourexecutablesandcomponentsfromdirectorytodirectory.VisualBasic.NETisnowfullyintegratedwiththeotherMicrosoftVisualStudio.NETlanguages.Notonlycanyoudevelopapplicationcomponentsin英文资料-2-differentprogramminglanguages,yourclassescannowinheritfromclasseswritteninotherlanguagesusingcross-languageinheritance.Withtheunifieddebugger,youcannowdebugmultiplelanguageapplications,irrespectiveofwhethertheyarerunninglocallyoronremotecomputers.Finally,whateverlanguageyouuse,theMicrosoft.NETFrameworkprovidesarichsetofAPIsforMicrosoftWindows®andtheInternet.WhyIsVisualBasic.NETNot100%Compatible?ThereweretwooptionstoconsiderwhendesigningVisualBasic.NETretrofittheexistingcodebasetorunontopofthe.NETFramework,orbuildfromthegroundup,takingfulladvantageoftheplatform.Todeliverthefeaturesmostrequestedbycustomers(forexample,inheritance,threading),toprovidefullanduninhibitedaccesstotheplatform,andtoensurethatVisualBasicmovesforwardintothenextgenerationofWebapplications,therightdecisionwastobuildfromthegrounduponthenewplatform.Forexample,manyofthenewfeaturesfoundinWindowsFormscouldhavebeenaddedtotheexistingcodebaseasnewcontrolsormoreproperties.However,thiswouldhavebeenatthecostofalltheothergreatfeaturesinherenttoWindowsForms,suchassecurityandvisualinheritance.OneofourmajorgoalswastoensureVisualBasiccodecouldfullyinteroperatewithcodewritteninotherlanguages,suchasMicrosoftVisualC#orMicrosoftVisualC+®,andenabletheVisualBasicdevelopertoharnessthepowerofthe.NETFrameworksimply,withoutresortingtotheprogrammingworkaroundstraditionallyrequiredtomakeWindowsAPIswork.VisualBasicnowhasthesamevariabletypes,arrays,user-definedtypes,classes,andinterfacesasVisualC+andanyotherlanguagethattargetstheCommonLanguageRuntime;however,wehadtoremovesomefeatures,suchasfixed-lengthstringsandnon-zerobasedarraysfromthelanguage.VisualBasicisnowatrueobject-orientedlanguage;someunintuitiveandinconsistentfeatureslikeGoSub/ReturnandDefInthavebeenremovedfromthelanguage.英文资料-3-Theresultisare-energizedVisualBasic,whichwillcontinuetobethemostproductivetoolforcreatingWindows-basedapplications,andisnowpositionedtobethebesttoolforcreatingthenextgenerationWebsites.UpgradingtoVisualBasic.NETVisualBasic.NETenablesafundamentalshiftfromtraditionalWindowsdevelopmenttobuildingnext-generationWebandn-tierapplications.Forthisreason,yourcodewillneedtobeupgradedtotakeadvantageofVisualBasic.NET.ThishappensautomaticallywhenyouopenaVisualBasic6.0projectinVisualBasic.NET:theUpgradeWizardstepsyouthroughtheupgradeprocessandcreatesanewVisualBasic.NETproject(yourexistingprojectisleftunchanged).Thisisaone-wayprocess;thenewVisualBasic.NETprojectcannotbeopenedinVisualBasic6.0.Whenyourprojectisupgraded,thelanguageismodifiedforanysyntaxchangesandyourVisualBasic6.0FormsareconvertedtoWindowsForms.Inmostcases,youwillhavetomakesomechangestoyourcodeafteritisupgraded.ThisisrequiredbecausecertainobjectsandlanguagefeatureseitherhavenoequivalentinVisualBasic.NET,orhaveanequivalenttoodissimilarforanautomaticupgrade.Aftertheupgrade,youmayalsowanttochangeyourapplicationtotakeadvantageofsomeofthenewfeaturesinVisualBasic.NET.WorkingwithBothVisualBasic6.0andVisualBasic.NETVisualBasic.NETsupportsupgradingVisualBasic6.0projects;ifyouhaveaprojectwritteninVisualBasicversions1to5,werecommendyouloaditintoVB6(choosingtoupgradeMicrosoftActiveX®controls),compile,andsavetheprojectbeforeupgradingittoVisualBasic.NET.BothVisualBasic.NETandVisualBasic6.0canbeinstalledonthesamecomputerandrunatthesametime.Likewise,applicationswritteninVisualBasic.NETandVisualBasic6.0canbeinstalledandexecutedonthesamecomputer.ComponentswritteninVisualBasic.NETcaninteroperatewithCOMcomponentswritteninearlierversionsofVisualBasicandotherlanguages.Forexample,youcandropanActiveXcontrolwritteninVisualBasic6.0ontoaVisualBasic.NET英文资料-4-WindowsForm,useaVisualBasic6.0COMobjectfromaVisualBasic.NETclasslibrary,oraddareferencetoaVisualBasic.NETlibrarytoaVisualBasic6.0executable.ComponentscompiledwithVisualBasic.NEThavesubtlerun-timedifferencesfromcomponentscompiledwithVisualBasic6.0.Forstarters,becauseVisualBasic.NETobjectsarereleasedthroughgarbagecollection,whenobjectsareexplicitlydestroyed,theremaybealagbeforetheyareactuallyremovedfrommemory.Thereareadditionaldifferencessuchasthevariant/objectchangesdescribedlaterinthisdocument.ThecombinedresultofthesedifferencesisthatVisualBasic.NETapplicationswillhavesimilarbutnotidenticalrun-timebehaviortoVisualBasic6.0applications.Inaddition,VisualBasic.NETmakesbinarycompatibilitybetweenVisualBasic.NETcomponentsandthoseinVisualBasic6.0unnecessary.Componentsnowhaveamorerobustversioninganddeploymentsystemthaneverbefore,filescanbedeployedbysimplycopyingtoadirectory(nomoreRegSvr32),andupgradingtoanewversionofacomponentisassimpleasreplacingtheoldfilewithanewfile.Allyouhavetodoisensureclassesandmethodsarecompatiblewiththepreviousversion.ArchitectureRecommendationsThe.NETplatformimprovesuponpreviousarchitectures,andaddsgreatersupportforscalabilityanddistributedapplicationsthoughdisconnecteddataaccess,HTTP-basedmessagetransport,andfile-copybaseddeployment(nomoreregisteringofcomponents).Tobesttakeadvantageofthesefeatures,youshoulddesignyourapplicationswithanarchitecturesimilartothatyouwoulduseinVisualBasic.NET.Browser-basedApplicationsVisualBasic6.0andMicrosoftVisualStudio®6.0offeredseveraltechnologiesforcreatingbrowser-basedInternetandintranetapplications:WebclassesDHTMLprojects