- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
3.2 For loop statement Sub EvenNumber() dim I as integer for I = 2 to 20 step 2 Debug.Print I;”--” Next I End sub . * 3.3 Do loop statement Sub Average() dim I as integer, avg as single, x as Integer x = Input(“Input a number:”) do while x-1 avg = avg + x I = I + 1 loop MsgBox “the avg is:” avg / I End sub . * 3.2 Do loop statement (Con.) How to improve previous program . * 4 Subroutine Introduction to subroutine Sub Function Parameters . * 4.1 Introduction to subroutine What is subroutine A segment code To Implement some defined function Why we need subroutine ?? How to write subroutine Function separated . * 4.2 Sub Subroutine declaration form: [Public or Private] Sub SubroutineName (Param1 As DataType1, Param2 As DataType2,...) Statements End sub . * 4.2 Sub (Con.) Sub Data_Plus() Dim A As Integer, B As Integer Dim C As Integer, D As Integer A = 23: B = 12: C = 31: D = 19 Call Line1 Debug.Print A; Tab(6); B; Tab(12); A + B Debug.Print C; Tab(6); D; Tab(12); C + D Call Line1 Debug.Print A + C; Tab(6); B + D; Tab(12); A + B + C + D Call Line1 End Sub Sub Line1() Dim I As Integer For I = 1 To 15 Debug.Print -; Next I Debug.Print End Sub . * 4.2 Sub (Con.) Sub InputData() Dim X As Integer, Y As Integer X = InputBox(“Datum1): Y = InputBox(“Datum2) Call DataPlus(X, Y) DataSub X, Y End Sub Sub DataPlus(A As Integer, B As Integer) Dim Sum As Integer Sum = A + B MsgBox A + B = Sum End Sub Sub DataSub(X As Integer, Y As Integer) Dim Subst As Integer Subst = X - Y MsgBox X - Y = Subst End Sub . * Laboratory work Input and debug follow program: Requirement: Input the program Correct the syntax error Tracing the program excution . * Laboratory work (Con.) Program 1: Sub Today() MsgBox 今天的日期是 Date ,距2008年1月1日还有 (#1/1/2008# - Date) 天 End Sub . * Laboratory work (Con.) Program 2: Sub Root() Dim A As Integer, B As Integer, C As Integer
文档评论(0)