嗔秤戻幣�哉膵�云利匈嬉蝕湊蛸賜�塋床四衲���萩晦編報炎嘔囚^泡仟 ̄云利匈�《超噌�殻窟�嵌虜隆輓麈觚翹瀘卉韮�仍仍�。� 烏御危列
浪慕利 卦指云慕朕村 厘議慕尺 厘議慕禰 TXT畠云和墮 序秘慕杏 紗秘慕禰

VB2008貫秘壇欺娼宥(PDF鯉塀哂猟井)-及13嫗

梓囚徒貧圭�鮗� ○ 賜 ★ 辛酔堀貧和鍬匈��梓囚徒貧議 Enter 囚辛指欺云慕朕村匈��梓囚徒貧圭�鮗� ● 辛指欺云匈競何��
!!!!隆堋響頼��紗秘慕禰厮宴和肝写偬堋響��




tions should be general�察�with added interpretation notes saying things like�察 �If dog is stubborn�察 �

repeat。 ̄ 

     Converting this into puter´speak�察�the two sets of instructions are for two different  

processors or processors used in specific situations。 For example�察�there are server puters  

and client puters。 Each type of puter has different requirements。 A server puter  

needs to process data as quickly as possible�察�whereas a client puter needs to show data on  

the screen as quickly as possible。 There are pilers for each context�察�but to have the developer  

create multiple distributions with different piler��s�� or setting��s�� is inefficient。 The solution  


´´´´´´´´´´´´´´´´´´´´´´Page 42´´´´´´´´´´´´´´´´´´´´´´´

20         CH AP T E R   1   *    R E A DY �察  �ST E A DY �察  �G O � �



           is to create a set of instructions that are general�察�but have associated interpretation notes。 The  

            Framework then applies these instructions using the interpretation notes。 

                 The  Framework piles to instructions ��CIL�� that are then converted into processor

           specific instructions using notes embedded in the  Framework。 The  architecture is  

           illustrated in Figure 1´10。 



           Figure 1´10。  architecture 



                 In Figure 1´10�察�Visual Basic Express is responsible for converting the Visual Basic source  

           code into a CIL package。 The converted CIL package is a binary file that�察�when executed�察�requires a  

           mon language runtime ��CLR��。 Without a CLR installed on your puter�察�you cannot run  

           the CIL package。 When you installed Visual Basic Express�察�you installed the CLR in the back

           ground as a separate package。 Visual Basic Express is an application that allows you to develop  

           for the CLR�察�but it also uses the CLR。 

                 The CLR has the ability to transform your instructions in the CIL package into something  

           that the operating system and processor can understand。 If you look at the syntax of 

           patible languages�察�such as Visual Basic�察�C#�察�and Eiffel�察�you will see that they are not  

           similar。 Yet the CLR can process the CIL package generated by one of those languages because  

           a  piler�察�regardless of programming language�察�generates a set of instructions mon  

           to the CLR。 


´´´´´´´´´´´´´´´´´´´´´´Page 43´´´´´´´´´´´´´´´´´´´´´´´

                                                                        C H AP TE R   1   *    R E AD Y �察  �ST E AD Y �察  �G O� �21 



     When using the  Framework�察�you are writing for the CLR�察�and everything you do must  

be understood by the CLR。 Generally speaking�察�this is not a problem if you are writing code in  

Visual Basic。 The following are some advantages of writing code targeted to the CLR�此�



     Memory and garbage collection�此�Programs use resources such as memory�察�files�察�and so on。  

      In traditional programming languages�察�such as C and C�����察�you are expected to open and  

      close a file�察�and allocate and free memory。 With �察�you don¨t need to worry about closing  

     files or freeing memory。 The CLR knows when a file or memory is not in use and will auto

     matically close the file or free the memory。  



*Note  Some programmers may think that the CLR promotes sloppy programming behavior�察�as you don¨t  

need to clean up after yourself。 However�察�practice has shown that for any plex application�察�you will waste  

time and resources figuring out where memory has not been freed。 



      Custom optimization�此�Some programs need to process large amounts of data�察�such as that  

     from a database�察�or display a plex user interface。 The performance focus for each is on  

      a different piece of code。 The CLR has the ability to optimize the CIL package and decide  

     how to run it as quickly and efficiently as possible。  



      mon Type System ��CTS���此�A string in Visual Basic is a string in C#。 This ensures that  

     when a CIL package generated by Visual Basic talks to a CIL package generated by C#�察 �

     there will be no data type misrepresentations。 



      Safe code�此�When writing programs that interact with files or memory�察�there is a possibility  

     that a program error can cause security problems。 Hackers will make use of that security  

      error to run their own programs and potentially cause financial disaster。 The CLR cannot  

      stop application´defined errors�察�but it can stop and rein in a program that generates an  

      error due to incorrect file or memory access。 



     The benefit of the CLR is allowing developers to focus on application´related problems�察 �

because they do not need to worry about infrastructure´related problems。 With the CLR�察�you  

focus on the application code that reads and processes the content of a file。 Without the CLR�察 �

you would need to also e up with the code that uses the content in the file and the code that  

is responsible for opening�察�reading�察�and closing the file。  



The Important Stuff to Remember 



This chapter got you started working with Visual Basic in an IDE。 Here are the key points to  

remember�此�



     o  There are three major types of Visual Basic programs�此�Windows applications�察�console  

        applications�察�and class libraries。 



     o  A Windows application has a user interface and behaves like other Windows applica

        tions ��such as Notepad and Calculator��。 For Windows applications�察�you associate events  

        with actions。 


´´´´´´´´´´´´´´´´´´´´´´Page 44´´´´´´´´´´´´´´´´´´´´´´´

22        CH AP T E R   1   *    R E A DY �察  �ST E A DY �察  �G O � �



                o  A console application is simpler than a Windows application and has no events。 It is used to  

                   process data。 Console applications generate and accept data from the mand line。 



                o  You will want to use an IDE to manage your development cycle of coding�察�debugging�察 �

                   and application execution。 



                o  Among other things�察�IDEs manage the organization of your source code using projects  

                   and solutions。 



                o  In an IDE�察�keyboard shortcuts make it easier for you to perform operations that you will  

                   do repeatedly。 For example�察�in Visual Basic Express�察�use Ctrl��S to save your work and  

                   Ctrl��F5 to run your application without debugging。 



                o  Visual Basic Express projects contain plain´vanilla files and specialized groupings。 When  

                   dealing with specialized groupings�察�make sure that you understand how the groupings  

                   function and modify only those files that you are meant to modify。 



           Some Things for You to Do 



           The following are some questions related to what you¨ve learned in this chapter。 Answering  

           them will help you to get started developing your projects in the IDE。 



           *Note  The answers/solutions to the questions/exercises included at the end of each chapter are available with  

           this book¨s downloadable code�察�found in the Source Code/Download section of the Apress web site ��http��// 

           apress。��。 Additionally�察�you can send me an e´mail message at christianhgross@gmail。。 



                1。  In an IDE�察�solutions and projects are used to classify related pieces of functionality。 The  

                    analogy I used talked about cars and car pieces。 Would you ever create a solution that  

                    contained unrelated pieces of functionality�拭�For example�察�would you create an airplane  

                    solution that contained car pieces�拭�



                2。  Projects are based on templates created by Microsoft。 Can you think of a situation where  

                    you would create your own template and add it to Visual Basic Express�拭�



                3。  In the So
卦指朕村 貧匯匈 和匯匈 指欺競何 壘��0�� 家��0��
隆堋響頼��紗秘慕禰厮宴和肝写偬堋響��
梁椣戻幣�� 梁心弌傍議揖扮窟燕得胎��傍竃徭失議心隈才凪万弌誌育断蛍�輌臆惨軼僑〃�燕慕得珊辛參資誼持蛍才将刮襲潜��範寔亟圻幹慕得 瓜寡追葎娼得辛參資誼寄楚署衛、持蛍才将刮襲潜填��