Tải bản đầy đủ - 0 (trang)
Appendix E.  What's New and Different in Visual Basic .NET 2003

Appendix E.  What's New and Different in Visual Basic .NET 2003

Tải bản đầy đủ - 0trang

E.1.LanguageChangesinVB.NET2003

VisualBasic.NET2003includedtwochangesofnoteinits

implementationoftheVisualBasiclanguage.



E.1.1.BitShiftOperators

Thecollectionofbitwiseoperatorsincreasedin2003withthe

additionofthebitshiftoperators,<<(ShiftLeft)and>>(Shift

Right).Alsoaddedweretheirassignmentoperatorequivalents,

<<=and>>=.TheseoperatorsarediscussedinChapter5.



E.1.2.DeclarationinForLoops

VisualBasic.NET2002introducedblock-leveldeclarationtothe

language,allowingyoutouseDimstatementswithinanIf

statement,aloop,orotherblockconstructsandhavethat

variableapplyinscopeonlytothatblock.Theotherbenefitof

suchusagewasthatalocalvariablecouldbedefinedatthe

momentofitsfirstuseinaprocedure.However,thiswasnot

trueforloopvariablesusedtocontrolForstatements.

Inthe2003release,Forstatementscannowincludea

declarationfortheloopingvariabledirectlyintheForstatement.

ThenewsyntaxaddsanAsclausetotheloopvariablename.

ThefollowingVB.NET2002code:

DimcounterAsInteger

Forcounter=1To10

MsgBox(counter)

Nextcounter



cannowbewritteninVB.NET2003as:

ForcounterAsInteger=1To10

MsgBox(counter)

Nextcounter



Aswithblockvariables,theseForloopvariableshavevalid

scopeonlywithintheblock(theForstatementblock,inthis

case).Also,ifyouwanttoaddasecondloopatthesameblock

leveltoyourcodeusingthesamevariablename,youmust

includetheAsclausetothatsecondloop,asitsdefinitiondoes

notcarryfromonelooptothenext.

ThisnewsyntaxcanalsobeusedwithForEachstatements.

ForEachplayerAsTeamMemberInbaseballTeam

MsgBox(player.Name)

Nextplayer



AppendixF.What'sNewandDifferentin

VisualBasic2005

The2005releaseofVisualBasicincludesmajorenhancements

overtheprevious2003edition.Itsinternalversionnumberis

8.0,anditmatchesarelatedmajorupdateofthe.NET

Framework,nowatVersion2.0.Microsoftalsoremovedthe

".NET"termfromthenameofeachproductintheVisualStudio

family.VisualBasic.NETisnowknownofficiallyasVisualBasic.

Thisreleaseincludesmanyusabilityenhancements,manyof

whicharerealizedonlywhenusingtheVisualStudio2005

product.Forinstance,VisualBasicnowincludesEditand

Continue,afeatureavailableinallpre-.NETversionsofVisual

Basic,whichallowssourcecodetobemodifiedinanactively

runningprogram.Thechangesareimmediatelyreflectedinthe

runningcode.Aparallelchange,design-timeexpression

evaluation,processesindividualsource-codestatements

withouttheneedtofullybuildanapplication(althoughVisual

Studioactuallybuildsamini-applicationinthebackgroundto

evaluatetheexpression).

TheVisualStudioenvironmentalsoincludesenhancederror

reporting,includingrecommendationsonchangingerrantVB

code.Codesnippets,auto-completionfeatures,andenhanced

projectanditemtemplatesalsosupportfastercode

development.

WhiletheseandotherVisualStudio-levelenhancementsmake

VisualBasicamoreproductivelanguage,thisappendixfocuses

onthelanguageenhancementsincludedinthe2005release.

VisualBasic2005includesseveralnewkeywordsthatmayhave

beenusedasvariableormembernamesinyourpre-2005

VisualBasiccode.Thisreleaseincludesacommand-lineutility,



vb7to8.exe,whichchecksexistingVisualBasiccodefor

keywordconflicts.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Appendix E.  What's New and Different in Visual Basic .NET 2003

Tải bản đầy đủ ngay(0 tr)

×