土地資源調(diào)查與評(píng)價(jià)_第1頁(yè)
土地資源調(diào)查與評(píng)價(jià)_第2頁(yè)
土地資源調(diào)查與評(píng)價(jià)_第3頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Beginning Visual Basic1. Introducing Visual BasicA Story About Bill and PaulBack in the early 1970' s, Bill and Paul were friends at LakesideSchool in Seattle, Washington. Bill and Paul enjoyed working with computers and wrote many games they could play - games like Tic-Tac-Toe and moon landing

2、games. These computer games were writte n in a computer Ianguage calledBASIC(which stands forBeginner ' s All-Purpose SymbolicI nstructionCode). When the first small computer was developed in themid 19 70' s, Bill and Paul had just started college. They had improved their computer skills by

3、then and were able to tell that new computer how to use the BASIC Ian guage. They actually sold their vers ion of the BASIC Ian guage to other people (it cost $350 and was stored on a cassettetape). They started making money selling BASIC and decided to start a compa ny. You may have heard of their

4、compa ny - Microsoft! Bill is Bill Gates, who still runs Microsoft and is worth many billions of dollars, and Paul is Paul Alle n, who no Ion ger works for Microsoft, but has his own bus in ess ven tures in cludi ng computers and software, professi onal sports teams, and real estate developme nt.Yes

5、, the first product sold by Microsoft was the BASIC computerIanguage. Microsoft ' s name for their BASIC Ianguage product has changed over the years, hav ing n ames like GW-BASIC, QuickBasic and QBasic, with the newest version being called Visual Basic . Visual Basic is one of the easiest progra

6、m ming Ian guages to lear n. Yet, eve n though it is easy to lear n and to use, Visual Basic can also be used to develop very powerful computer programs. Many computer games are writte n in Visual Basic, bus in esses use Visual Basic to man age their databases, webmasters use Visual Basic in develop

7、 ing web pages, and people like yourself use Visual Basic to build Win dows applicati ons they want and n eed in their everyday life. In these notes, you will learn how to use Microsoft' sVisual Basic to write your own computer programs. You may not become a billiona ire like Bill and Paul, but

8、hopefully you' ll have some funlearning a very valuable skill.Let's Get StartedLearning how to use Visual Basic to write a computer program (like learning anything new) involves many steps, many new terms, and many new skills. We will take it slow, describing each step, term, and skill in de

9、tail. Before starting, we assume you know how to do a few things:? You should know how to start your computer and use the mouse.? You should have a little knowledge on working with your operating system (Windows 95, 98, or NT).? You should know how to resize and move windows around on the screen.? Y

10、ou should know how to run an application on your computer by using the Start Menu.? You should know how to fill in information in Windowsthat may pop up on the screen.? You should know about folders and files and how to find them on your computer.? You should know what file extensions are and how to

11、 identify them. For example, in a file namedExample.ext ,the three letters ext are called the extension.You have probably used all of these skills if you've ever used a wordprocessor, spreadsheet, or any other software on your computer. If you think you lack any of these skills, ask someone for

12、help or consult one of the many books introducing the Windows operating system.Let's get going. And, as we said, we're going to take it slow.In this first class, we will learn how to get Visual Basic started on a computer, how to load a program (or project) into Visual Basic, how to run the

13、program, how to stop the program, and how to exit from Visual Basic. It will be a good introduction to the many new things we will learn in the classes to come.Starti ng Visual BasicWe assume you have some versi on of Visual Basic in stalled and operational on your computer. If you don ' t, you

14、need to do this first. Aga in, this might be a good place to ask for some one' s help if you n eedit. Over the past several years, there have bee n many versi ons of VisualBasic. You will be able to do this class using Visual Basic 4.0 (32 bitversion), Visual Basic 5.0, or the new Visual Basic 6

15、.0. Throughout theno tes, we will refer to Visual Basic by its abbreviati onVB and you willbe told what to do depe nding on what versi on of Visual Basic you areusing. If you are using Visual Basic 4.0, look for the abbreviati onVB4for in formatio n particular to your versi on. If you are using Visu

16、alBasic 5.0, look for the abbreviati onVB5for in formatio n particular toyour vers ion. An d, if you are using Visual Basic 6.0, look for the abbreviati onVB6for in formatio n particular to your versi on.To start Visual Basic:? Click on the Start butt on on the Win dows task bar.? Select Programs, t

17、hen Microsoft Visual Basic # (where #is your versi on of Visual Basic).? Click on Visual Basic # (where aga in # is your versi on).(Some of the headings given here may differ slightly on your computer, but you should have no trouble finding the correct on es.) The Visual Basic program should start.

18、Several win dows will appear on the scree n, with the layout depe nding on your vers ion of VB.專業(yè)資料 .VB4Title BarMain Menu高 Proj ectl - Microsoh Visual Basic designFie EditInsert Run Tcoh Addln$ He|pToolbarr_-|n|x|I之舊I気I刮窗|答曲I詁|訃I廠陰心I 土1 &20i 1125*ArSV-ip尋【気4J±I±i&u農(nóng)、1囲甲叫ijaPope“i併

19、-FmmAppearance1 VDAutoFl edrawFalseBackColoitMGOOOODOFt -BarderStyle2 - SizableCaptionFormlCfciGontrohTrueConliolBoxTrueDrai/jMode13 - Copy PenDravlStylea-SolidH raiAAft/idkh1 | Forml FormProiecHViefFarmView CedeVB5:Title BargjFoimlForm!Main Menu專業(yè)資料.VB6:Title BarMain MenuToolbar/槁 Projectl - Micros

20、oft Visual Basic designFile Edit View rajec t Formst DeLug gun Query &ia4rrim Tools Add-fn Window HelpII 越皆帖普澱法Q OfProperties-Foim12J3Alphabetic | categorized | CNamg) Appearance 1 - 3F>Forml FomnGeneralForniLAutoRedrau False BcKColor 3order5tle Caption ClipContrate 匚 q ritrclBux DrawMode Dra

21、wStyle DraiWVidth inahlEd Fillcolor Fillstyle Font &H0OOOOC z' 旨Eobte Forrnl TrueTrue13-CopyFeio - solidTrue &Hoaooac L - T齪叩 MS Sars Serif2J2JLJ=1=ontT rarspare=ore ColorHasDCTrue&H8X00CTrueWhen starting VB5 or VB6, a dialog box asking aboutNew Project type mayappear. If it does, ju

22、st click theOpe nbutt on.Let' s point out just a few itemson the screen. At the top of thescreen is the Visual Basic Main Window At the top of the main window is the Title Bar. The title bar gives us information about what program we' re using and what Visual Basic program we are working wit

23、h. Below the title bar is theMain Menufrom where we can control the Visual Basicprogram. You should be familiar with how menus work from using other programs like word processors and games. Un der the main menu is theToolbar . Here little buttons with pictures also allow us to controlVisual Basic, m

24、uch like the main menu. If you put the mouse cursor over one of these buttons for a second or so, a little tooltip ' will pop up and tell you what that particular button does - try it! Almost allWindows applications (spreadsheets, word processors, games) have toolbars that help us do different t

25、asks. This is the purpose of the Visual Basic toolbar. It will help us do most of our tasks. We'll worry about theother things on the screen later.Opening a Visual Basic ProjectWhat we want to do right now isope n a project . Programs writte nusing Visual Basic are referred to asprojects . Proje

26、cts include all thein formati on we n eed for our computer program. Whe n we are done writ ing our computer program using Visual Basic, we save it as a project.In cluded with these no tes are many Visual Basic projects you can ope n and use. Let ' s open one now.We will use the Visual Basic tool

27、bar to open a project. Look for a butt on on the toolbar that looks like a folder ope ning up. This is the Open Project butt on:Click on this butt on. AnOpe n Project win dow will appear.Find the folder n amedBeg inVB (sta nds forBegi nning VisualBasic). This is the folder that holds the no tes and

28、projects for this course. Open that folder.Find the folder n amedBVBProjects. This folder holds allthe projects for the course. In this folder are three other folders:VB4Projects (contains projects for VisualBasic 4.0, 32 bit version),VB5Projects (contains projectsfor Visual Basic 5.0), and VB6Proje

29、cts (contains projects for Visual Basic 6.0). Select the folder for your vers ion of Visual Basic.Remember how you got to this folder. Throughout the course, you will go to this folder to ope n projects you will n eed.Now, i n your project file, find a project file n amedSample. Ope nSample. Many wi

30、ndows are now on the screen. Look for a window thatlooks somethi ng like this - this isSample:If this window doesn' t show up when you open the project:VB4Click View on the main menu, the nForm.VB5, VB6: Click View on the main menu, thenObject .As an alter nate, if the wi ndow does not show up,

31、press theF7 fun cti onkey while holdi ng dow n < Shift >. This is a keyboard comma nd to show this particular wind ow. We' re going to spend a bit of time explaining everything that is displayed here. This will introduce you to some of the vocabulary we use in Visual Basic. There are lots

32、of terms used inVisual Basic. Don ' t try to memorize everything - you' ll see t hese new words many times through the course.We call the displayed project wi ndow aForm. All Visual Basicprojects or programs are built using forms. In fact, you have probably no ticed that all Win dows applica

33、tio ns are built using forms of some type. At the top of the form is theTitle Bar. It has an icon (littlepicture) related to the form, a descripti on of what the form does(Beg inning Visual Basic - Sample ), and three smaller butt tons thatcontrol form appearanee (we won ' t worry about these bu

34、tto ns right now). There are lots of other things on the form. These other things are the heart ' of a Visual Basic computer program.You see a set of square butt ons with object n ames n ext to them.You see pictures of objects. You see a set of round butt ons with colorn ames n ext to them. Ther

35、e is a little box you can type in with someth ingcalled a scroll bar on the right side. There' s a big butt on that saysBeep! There ' s a little device for picking the value of a number. And, there ' s a ball in a bi g recta ngle with a butt on that says Start and a little thing that loo

36、ks like a stopwatch. We call all of these other things on the formCon trols or Objects . Con trols provide anin terfaceor line of com muni cati on, betwee n you (or the user of your program) and the computer. You use the con trols to tell the computer certa in thin gs.The computer then uses what it

37、is told to determine some results and displays those results back to you through controls. By the way, the form itself is a control. If you've used any Windows applications,you've seen controls before- you probably just didn't know they werecalled controls. As examples, buttons on toolba

38、rs are controls, scroll bars to move through word processor documents are controls, menu items are controls, and the buttons you click on when opening and saving files are controls.I think you get the idea that controls are a very important part of Visual Basic, and you 're right. They are the m

39、ost important part of Visual Basic - they are what allow you to build your applications. We will spend much of this course just learning about controls. Right now, though, let 's run this program and get some insight into how a Visual Basic project (and its controls) works. Before we leave thoug

40、h, look at the title bar in the Visual Basic main window - notice the bracketed word design . This tells us that Visual Basic is inDesign mode. That isthe mode used to build a Visual Basic project. Always look at this title bar to see what mode Visual Basic is working in.Running a Visual Basic Proje

41、ctAfter develop ing a Visual Basic project, you want to start or runthe program. This gets the program going and lets the user in teract withthe controls on the form and have the computer do its assigned tasks. Wecan run a project using the toolbar. Look for a butt on that looks likeSample (the proj

42、ect we ope nedthe Play butt on on a VCR, CD player, or cassette tape player:Click this butt on to run previously).The project form will appear and look something like this:I). Beginning Visual Basic - Sample-Stuff廠CarI r ruck廠 HouseB Cardr Eyeball 廠 FootballNotice a few things have changed. All the

43、objects have disappeared. The background color of the form is blue. The circle button next toBlue hasa black dot in it. The little stopwatch control has disappeared. The little ball has dropped to the bottom of the big rectangle. What happened? We'll find out how and why all this happened as we

44、learn more about Visual Basic. Also, notice (in the main window) that Visual Basic is now in Run mode.The project is now running, but what is it doing? Nothing is happening, or is it? At this point, Visual Basic is waiting for you, the user, to do something. We say your Visual Basic project is waiti

45、ng for an event to occur. Nothing can happen in a Visual Basic program until an event occurs. We call Visual Basic anevent-driven programminglanguage. So, let 's cause an event.An event occurs when you do something on the form - click on something with the mouse, type something in places where w

46、ords can go, or maybe drag an object across the form. In the upper left corner of the form is a group of six boxes within a rectangular region with the heading Stuff . Each little box has an object name printed next to it. Click on one of these boxes. Notice what happens. A check appears in the sele

47、cted box, indicating box selection, and the object named by that box appears on the screen. When we click on a box, we cause an event, called a Click event. The computer recognizes the event and does what you have told it to do (through your computer program) if that particular event occurs. In this

48、 case, the event tells the computer to display the selected object. Click on the box again. The check mark and the objectdisappear. You have caused ano ther eve nt and told the computer to make the object disappear. This particular control is called acheck box.Notice you can check as many boxes as y

49、ou want, pick ing which objects (if any) you want displayed on your scree n. Check boxes are used whe n you want to select items from a list. Two other con trols are used in this example. The recta ngular regi on the check boxes are contained is called a frame . The region each object picture is dis

50、played in is called an image control. Now, let ' s look at causing events with the other controls on the form.Near the middle of the scree n is a group of four round butt ons in aframe with the headi ng Color. Each butt on has a color n ame prin ted n ext to it. The Blue butt on has a black dot

51、in it, i ndicati ng it is the curre ntly selected color (no tice the form is blue). Click on ano ther of these butt ons. Notice what happe ns. The form color cha nges to the selected color. This Click eve nt tells the computer to cha nge the form backgro und color. Notice that whe n you select a new

52、 color, the black dot appears in the selected butt on and disappears in the previously selected butt on. Un like the check boxes we saw earlier, you can only select one of these butt ons. This makes sense - the form can only be one color!These round buttons are calledoption buttons . Option buttons

53、are usedwhe n you n eed to choose exactly one opti on from a list of many.Under the Stuff frame is another frame with the headingPick aNumber There we see a number displayed in a control called alabel .Under the label is another control called ascroll bar. You ' ve probablysee n scroll bars in o

54、ther applicati ons you have used. The scroll bar is used to cha nge the displayed nu mber. Click on the arrow on the rightside of the scroll bar. The displayed value will increase by 1. Continued clicking on that arrow will continue to increase the value. Click on the white area to the left of the a

55、rrow. The value will increase by 10. Click on the little bar (called a thumb) in the middle of the scroll bar and drag it right, then left. Notice that, too, changes the displayed value. In this example, the computer is responding to the scroll bar ' s Changeevent, which occurs each time the scr

56、oll bar thumb moves. The Change event tells the computer that the scroll bar value has changed and allows the new value to be displayed in the label control.Under the Pick a Number frame is a region with a scroll bar on the right side. This control is called a text box. You can click in it, then typ

57、e in any text you want. Try it. The text box is like a little word processor in itself. Each time you type something in the text box, several events occur. There is aKeyPress event when you press a key anda Changeevent that is called each time the text in the box changes.Next to the text box is a bu

58、tton that saysBeep! Click the buttonand you should hear a beep on your computer's speaker. This control iscalled a commandbutton and is one of the most widely used controls in Visual Basic. TheClick event told the computer to make the speakerbeep.The last thing on our form is a tall, yellow, rectangular control called a picture box that contains a litt

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論