VB6 -> VB.NET 2008

Download VB6 ->  VB.NET 2008

Post on 15-Jan-2016

58 views

Category:

Documents

0 download

Embed Size (px)

DESCRIPTION

VB6 -> VB.NET 2008. Mgr. Michal Neuwirth ISV Teachnical Readin e s s. Obsah. .NET Framework VB6 vs VB.NET 200 8 OOP API, COM, COM+ Windows Forms Pstup k datm Migration wizard. Co .NET pin. Windows aplikace, Webov aplikace Windows a Web sluby Konzolov aplikace - PowerPoint PPT Presentation

TRANSCRIPT

VB6 -> VB.NET 2005

VB6 -> VB.NET 2008Mgr. Michal NeuwirthISV Teachnical ReadinessObsah.NET FrameworkVB6 vs VB.NET 2008OOPAPI, COM, COM+Windows FormsPstup k datmMigration wizardCo .NET pinWindows aplikace, Webov aplikaceWindows a Web slubyKonzolov aplikaceAplikace pro mobiln zazenAplikace pro TabletPCVvoj pro Servery SQL, Biztalk, MOSS 2007, ....Pouvn XMLRychl vvoj aplikac pomoc Visual StudiaVB 6.0 aplikan prostedActiveX DesignersCOM ObjectsOperating SystemCOM+ ServicesWin32 API CallsCOMDirectX TypelibADOActiveX ControlsData BindingVB RuntimeRuntime FunctionsFormsMemory ManagementIntrinsic ObjectsUser ControlsActiveX DocumentsWeb ClassesData ReportData Environment VB ApplicationTechEd 20024This is the Visual Basic 6.0 application environment.

Base level is COMDirectX, ADO, ActiveX Controls, and DataBinding are built on top of COM They are essentially the runtime Pechod z VB6 na .NETActiveX DesignersCOM ObjectsOperating SystemCOM+ ServicesWin32 API CallsCOMDirectX TypelibADOActiveX ControlsData BindingVB RuntimeRuntime FunctionsFormsMemory ManagementIntrinsic ObjectsUser ControlsActiveX DocumentsWeb ClassesData ReportData Environment VB ApplicationTechEd 20025Pechod z VB6 na .NETOperating SystemCOM+ ServicesWin32 API CallsCommon Language RuntimeActiveX DesignersCOM ObjectsDirectX TypelibADOActiveX ControlsData BindingVB RuntimeRuntime FunctionsFormsMemory ManagementIntrinsic ObjectsUser ControlsActiveX DocumentsWeb ClassesData ReportData Environment VB ApplicationTechEd 20026Common Language SpecificationPechod z VB6 na .NETOperating SystemCOM+ ServicesWin32 API CallsCommon Language RuntimeADO .NET and XMLASP.NETWeb Forms, ServicesBase Class LibrariesWindows FormsVB ApplicationTechEd 20027Pechod z VB6 na .NETCommon Language SpecificationOperating SystemCOM+ ServicesWin32 API CallsCommon Language RuntimeADO .NET and XMLASP.NETWeb Forms, ServicesBase Class LibrariesWindows FormsVB ApplicationVBC#C++J#PerlOther LanguagesVisual Studio.NETTechEd 20028Common Language Specification.NET Framework a RuntimeOperating SystemCOM+ ServicesWin32 API CallsCommon Language RuntimeADO .NET and XMLASP.NETWeb Forms, ServicesBase Class LibrariesWindows FormsVBC#C++J#PerlOther LanguagesVisual Studio.NETTechEd 20029.NET FrameworkGarbage CollectorAutomatick systm na itn pamtiUvoluje z pamti nepotebn objekty, ne hned, ale v rmci garbage collectionNastaven objektu na Nothing objekt nezni, pouze piprav ke znienAssemblySamopopisn souborObsahuje metadata, vkonn kd, ....Side by SideVce verz me bet vedle sebeKonfiguranm souborem lze nastavit jak verze pouvatTechEd 200210.NET FrameworkSoust .NET FrameworkuMicrosoft.VisualBasic.DLLGlobal Assembly CacheMsto kam se instaluj sdlen assemblyInstalaceXCopy.MSIClick-OnceCross-language a cross-platform ladn

Kompilace a bh aplikace

Zdrojov kdKompilacePi instalaci nebo pi prvnm zavoln kad metody

Kompiltor jazyka

Assembly

Vykonn

JIT Compiler

NativnKd

Code (IL)

Metadata12KEY MESSAGE: Lifetime of a .NET application.

SLIDE BUILDS: 4SLIDE SCRIPT:You can author your code in any .NET language. These include the Microsoft languages of C#, C++, VB.NET, J#, etc. In addition, there are a number of 3rd party .NET languages available, including COBOL and Eiffel.

BUILD 1:Regardless of the language, when you hit the compile button, it isnt really doing a compile in the traditional sense. Its really more like a translate.

BUILD 2:The output of a compile is written to an assembly.

BUILD 3:The assembly doesnt contain machine code, but another language called Microsoft Intermediate Language (MSIL). You can think of this as .NETs own platform independent assembly language. This is packaged into a file with a traditional .DLL or .EXE extension, but in .NET speak, this is referred to as an assembly.

BUILD 4:When you execute this code, the framework runs the IL through a Just In Time compiler, which produces native code that is optimized for the platform where the code is executing. The JIT happens once, and the native code is cached for subsequent executions. This makes JIT fundamentally different that a Java VM. The only thing that ever actually executes in the .NET framework is native machine code.

There is also an option to use a utility called NGEN to pre-JIT your code so that it doesnt have to be compiled on execution. However, with NGEN, you loose the ability to have the same IL optimized for the current platform.

SLIDE TRANSISTION: .NET reliabilityRestartKlient PC

MDAC!Click-Once instalaceSetup.exeDotnetfx.exeWeb ServerMdac_typ.exeCustom.msiAplikaceAplikaceDotnetfx.exeCustom.msiSetup.exeaa

13Visual Studio

VB6 vs vb.net 2008Typy aplikacArchitekturaVB6 projektVB 2008 ProjektDesktop aplikaceStandard .exe aplikaceWindows aplikace (Winforms)Web aplikaceIIS aplikaceASP.NET aplikace (WebForms)Distribuovan aplikaceAplikace vyuvajc DCOM, MTS a COM+Aplikace vyuvajc Webov sluby, .NET remoting, Enterprise Services nebo Windows Communication FoundationTypy projektKomponentaVB6 typVB 2008 typOut of process knihovnaActiveX.exeNen. Upgrade na Windows aplikaci i Class library.In-process knihovnaActiveX.dllClass libraryVisueln komponentaActiveX.ocxWindows control libraryVisueln komponenta uren pro hostovn v internetovch aplikacchActiveX documentNen. Pout UserControls pro ASP.NET.Datov typyVB 2008 je siln typov jazyk, kad promnn zn svj typ v dob pekladu a mus b inicializovan hodnotouVariant nen k dispoziciFixn dlka etzc nen k dispozici Dim name As String * 15PoleOption Base xVe VB6 uruje poten index pol.NET m vechny pole od 0 -> Option Base nen podporovnoDim MojePole (5) = obsahuje 6 poloek (0-5)Late bindingNkter defaultn vlastnosti se li ve VB6 a VB.NET

'VB6Dim o As ObjectSet o = Me.Label1o = "SomeText" 'default je Caption'VB.NETDim o As ObjectSet o = Me.Label1o.Text = "SomeText" CyklyWhile ... WendWhile ... End While

Parametry funkcByRef default VB6ByVal default VB 2008Optional - mus mt nastavenu vchoz hodnotu

Public Sub TestSub(Optional ByRef p1 As String = "")End SubMetodyParamArraypole objekt pedem neznmho potupouze jako posledn parametrmus bt explicitn uvedeno ByValpouze jedno-dimenzionln polevechny prvky maj stejn typSub StudentScores(ByVal Name As String, ParamArray ByVal Scores() As Integer) End Sub

StudentScores("Jamie", 10, 26, 32, 15, 22, 24, 16)EnumPublic Enum MyEnum FirstValue SecondValue ThirdValueEnd EnumPublic Sub TestEnum() Dim e As MyEnum e = SecondValueEnd SubMyEnum.SecondValueStructurePrivate Type MyType x As Integer y As Integer name As StringEnd TypePublic Sub TestUDT() Dim udt As MyType udt.name = "Joe" udt.x = 5 udt.y = 10End SubPrivate Structure MyType Dim x As Short Dim y As Short Dim name As StringEnd StructureVlastnostiPrivate mText As StringPrivate mObj As Object'TextPublic Property Get Text() As String Text = mTextEnd PropertyPublic Property Let Text(ByVal Value As String) mText = ValueEnd Property'ObjectPublic Property Get Obj() As Object Obj = mObjEnd PropertyPublic Property Set Obj(ByVal Value As Object) Set mObj = ValueEnd PropertyPrivate mText As StringPrivate mObj As ObjectPublic Property Text() As String Get Return mText End Get Set(ByVal Value As String) mText = Value End SetEnd PropertyPublic Property Obj() As Object Get Obj = mObj End Get Set(ByVal Value As Object) mObj = Value End SetEnd PropertyVlastnostiReadOnly obsahuje pouze blok GetWriteOnlyobsahuje pouze blok SetSet blok obsahuje implicitn parametr ValuePublic ReadOnly Property Obj() As Object Get Obj = mObj End GetEnd PropertyPublic WriteOnly Property TextW() As String Set(ByVal Value As String) mText_w = Value End SetEnd PropertyTry ' Catch ex As Exception '

Finally 'End Try fReRaise = False

OnError GoTo ErrHandler ' GoTo CleanUp

ErrHandler: If ' Then ' Else fReRaise = True End If

CleanUp: If fReRaise Then Err.Raise errNum On Error vs Try/Catch/FinallyOnError GoTo ErrHandler 'ErrHandler: If ' Then 'fReRaise = FalseTry ' Else fReRaise = True End IfCleanUp: If fReRaise Then Err.Raise errNumCatch ex As Exception 'Finally 'TechEd 200229Bottom line more elegant, readable, efficient

Explicit code Scenario Opening/processing fileWhen done or if error, close file.Step through code Any number of catch statements it specifies what we want to handle code is what closes the file.

Globln objektyVB6VB2008AppN/A. Informace jsou uloeny ve vce tdch nap. AssemblyInfo, My, ...ScreenN/A. K dispozici ve vce tdch Forms, Drawing, ...PrinterPrintDocumentClipboardClipboardDal vlastnostiVB6VB2008Array{ }As AnyMus bt uveden datov typCalendarSoust System.GlobalizationCurrencyDecimalDateZstv jako datov typ. Pro aktuln as Today()Debug.Assert, Debug.PrintSystem.DiagnosticsDefN/A kad promnn mus bt deklarovnaDoEventsSystem.Windows.Forms.Application.DoEvents()Empty, NullNothingIsEmpty, IsNullN/A k dispozici IsDBNulla IMP b(NOT a) OR bGoSubN/AIsMissingN/A vechny parametry mus mt vchoz hodnotuIsObjectIsReferenceLet, SetN/APSet, ScaleSystem.Drawing (GDI+)Struktury souborVB6.frm, .frx, .cls, .ctl., .bas, .res, .....VB.NET .vb, .resxoopNamespacesLogick hierarchick tdn tdSystem.Windows.FormsZajiuje jednoznanost jmenSystem.Windows.FormsNeuwirth.FormsJmenn prostor me bt rozloen do vce souborImports zkracuje syntaktick zpis

Dim frmForm1 As New System.Windows.Forms.FormImports System.Windows.FormsDim frmForm2 As New FormTechEd 200234Objektov programovnVB6 sten objektovNebyla podpora ddinosti, pouze implementace interfaceNebyla podpora konstruktor a destruktorVB 2008Vychz z konceptu .NET frameworku, kde je ve zaloeno na objektechPln objektov jazyk se vm vudyChyb jenom vcensobn ddinost

Tda (o