ࡱ> jli7  bjbjUU %(7|7| l  4>>>>>>>>bdddddd$ >>>>>>>>>>b>bl:,b>2 W > b0Rw>wbStopwatch Application - Drawing Controls *If you are using the electronic version of this document make sure you type the code in VB, do not copy and paste as you will not learn anything! 1. Start a new project. The idea of this project is to start a timer, then stop the timer and compute the elapsed time (in seconds). 2. Place three command buttons and six labels on the form. Move and size the controls and form so it looks something like this:  Stopwatch Application - Setting Properties Set properties of the form, three buttons, and six labels: Form1: BorderStyle 1-Fixed Single Caption Stopwatch Application Name frmStopWatch Command1: Caption &Start Timing Name cmdStart Command2: Caption &End Timing Name cmdEnd Command3: Caption E&xit Name cmdExit Label1: Caption Start Time Label2: Caption End Time Label3: Caption Elapsed Time Label4: BorderStyle 1-Fixed Single Caption [Blank] Name lblStart Label5: BorderStyle 1-Fixed Single Caption [Blank] Name lblEnd Label6: BorderStyle 1-Fixed Single Caption [Blank] Name lblElapsed In the Caption properties of the three command buttons, notice the ampersand (&). The ampersand precedes a button's access key. That is, in addition to clicking on a button to invoke its event, you can also press its access key (no need for a mouse). The access key is pressed in conjunction with the Alt key. Hence, to invoke 'Begin Timing', you can either click the button or press Alt+B. Note in the button captions on the form, the access keys appear with an underscore (_). 2. Your form should now look something like this:  Stopwatch Application - Attaching Code All thats left to do is attach code to the application. We write code for every event aresponse is needed for. In this application, there are three such events: clicking oneach of the command buttons. 1. Double-click anywhere on the form to open the code window. Or, select View Code from the project window. 2. Click the down arrow in the Object box and select the object named (general). The Procedure box will show (declarations). Here, you declare three form level variables: Option Explicit Dim StartTime As Variant Dim EndTime As Variant Dim ElapsedTime As Variant The Option Explicit statement forces us to declare all variables. The other lines establish StartTime, EndTime, and ElapsedTime as variables global within the form. 3. Select the cmdStart object in the Object box. If the procedure that appears is not the Click procedure, choose Click from the procedure box. Type the following code which begins the timing procedure. Note the Sub and End Sub statements are provided for you: Sub cmdStart_Click () Establish and print starting time StartTime = Now lblStart.Caption = Format(StartTime, "hh:mm:ss") lblEnd.Caption = "" lblElapsed.Caption = "" End Sub In this procedure, once the Start Timing button is clicked, we read the current time and print it in a label box. We also blank out the other label boxes. In the code above (and in all code in these notes), any line beginning with a single quote () is a comment. You decide whether you want to type these lines or not. They are not needed for proper application operation. Now, code the cmdEnd button. Sub cmdEnd_Click () Find the ending time, compute the elapsed time Put both values in label boxes EndTime = Now ElapsedTime = EndTime - StartTime lblEnd.Caption = Format(EndTime, "hh:mm:ss") lblElapsed.Caption = Format(ElapsedTime, "hh:mm:ss") End Sub Here, when the End Timing button is clicked, we read the current time (End Time), compute the elapsed time, and put both values in their corresponding label boxes. 5. And, finally the cmdExit button. Sub cmdExit_Click () End End Sub This routine simply ends the application once the Exit button is clicked. 6. Did you notice that as you typed in the code, Visual Basic does automatic syntax checking on what you type (if you made any mistakes, that is)? 7. Run your application by clicking the Run button on the toolbar, or by pressing . Pretty easy, wasnt it? 8. Save your application for future reference. */4$8>V\#+jkI M . / 0 ; c  I    % X a "&.P(Ʒ5OJQJ\^Jj'CJOJQJU^JaJCJOJQJ^JaJ5OJQJ\^JjOJQJU^J OJQJ^JCJaJ5CJOJQJ\^JaJD)*C./6Qo & F7$8$H$7$8$H$  &78@UV^y 7$8$H$_@ . / 1 2 3 4 5 6 7 8 9 : ; b c - . } 7$8$H$ = H I Y r D J 9OPfOuvw7$8$H$RZb CJOJQJ^JaJ5OJQJ\^J OJQJ^J5OJQJ\^Jwxyz{| .[=>bw{ h7$8$H$^h & F7$8$H$7$8$H$bc 7$8$H$ #0P/ =!"#$%'Dd  C \ADC:\My Documents\My Pictures\1.jpgR&EK/j*3r t^&D;F&EK/j*3r t^JFIFHHC       C  =Z!"1A5QUVcu#26Taqst$4BR%37&brCFd3R!1AQ"a#$24qr ?E>YC&Y9Ginx& ?D"!DCkyk3RWdT{r\G>ހtb6<7>ހ[c @{kt~> m|7>ހ[c @{kl~5?qoz m|7>ހ[c @{kl~5?qoz m|7>ހ[c @{kl~5?qozktn+>t~5?q*rJpRk.g{ZЭȯrĶ^jsF8OLO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߭^X#%^oȰ%ԡ66o`!鹾 H$^N 様Omw\D߬*0O ֺ`mcW o" NoB;~\qbj$li*0JFA-"b=[ s57h!H>/Kh{F$`>w`)4jd}Cj^}6S5.yG=$W0ׇom.d"K9j+Fo^ݶ2EC5R1&,+ ӴM %\e$qƱCTuɡS[ݴPIр0_A`:ixԱ4dSk2 'y\```d~Yܸ>d~Y'xTݑ?~v޸>d|Ϧw~+t {>ߦ{_f[ęo!2ZtiֲRk0GHX@U+#kcA*DGS۝*/q/n} l~ߗ6?~݀oO9loks'HFŚs2M9F2=PT*nsX˙ 2J93d9!HTF@Vg:@,mUCW7ycc fRJkhD!5 Np6.CuN1H%Oa$sڊu Q3R#bnǬ{1Pm0Us?~wSǞC`>u0KTΪDfKr"##2k_?FC"E>ٖA{YUaLb.yt5/64JjE*"juGu\;s2h _k JD`̫Ժyu{:݇bەc +ŵYt3:\6!utYs:ln yKs/:܀cbqRq FzzmV`yi]#M~Ai&w$WP@f.:v  6#~)@Y4ržq^*V GS,eJ#6r!@{B6.}xg_N|!)RGoH`f6 tߺܰTF,Ibz P֤}='IDs4RS %pK$Zetے*w\b'WRPpHnW%YX"11:l/uMl@eݤp67{ommTQӶk%թr@MQ"dy]y"H44b%OuE&yYBM! B^þ^`ʔ I$aEC3Zۄ*,z.[΢7xfh%(BKHv#I"hf@uD6WYrbtyxLr^E@+@X +Tp&'M%͈ BRsݦm4ʹʊ":vԍd:=ژCHɪ$L+$R8)4& Wĵ5$+3Cɤ77QUHKw ܚ%1mskrf Z3%hvi%{G#nc 5MȀlG3=D9s6r&[s=`K/kzn ɹ, $Zְ` HjĖ$&I&?fcœբ bw{bc 0000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000   w    (..| | 56<="#abcc CIAJ:\dgnew\u7\wks6.docCIAHC:\WINDOWS\Application Data\Microsoft\Word\AutoRecovery save of wks6.asdCIAHC:\WINDOWS\Application Data\Microsoft\Word\AutoRecovery save of wks6.asd+Tr+^`o(.^`.pLp^p`L.@ @ ^@ `.^`.L^`L.^`.^`.PLP^P`L.^`o(.^`.pLp^p`L.@ @ ^@ `.^`.L^`L.^`.^`.PLP^P`L.+                  @| | d| |  P@UnknownG:Times New Roman5Symbol3& :Arial71Courier"1hk&k&Q8 !0; 2Q(Stopwatch Application - Drawing ControlsCIACIA"C:\My Documents\My Pictures\1.jpg8X/ "C:\My Documents\My Pictures\2.jpg ՜.+,D՜.+,X hp|   ; ,Stopwatch Application - Drawing Controls Title< 8@ _PID_HLINKSA ;X"C:\My Documents\My Pictures\1.jpg8X/ "C:\My Documents\My Pictures\2.jpg  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKMNOPQRSTUVWXknYRoot Entry FmData m1TableLwWordDocument%(SummaryInformation(DocumentSummaryInformation8 CompObjjObjectPool``   FMicrosoft Word Document MSWordDocWord.Document.89q Oh+'0x  4 @ LX`hp)Stopwatch Application - Drawing ControlsordtopIAIANormalcCIA3Microsoft Word 9.0@J6@Bܺ@DQ8 Deepak Gautam ՜.+,D՜.+,X hp|   ; ,Stopwatch Application - Drawing Controls TitleL(@HP _PID_HLINKS A ;X