GehryTechnologyDigitalProjectVBA代码编写教程课件.ppt
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《GehryTechnologyDigitalProjectVBA代码编写教程课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- GehryTechnologyDigitalProjectVBA 代码 编写 教程 课件
- 资源描述:
-
1、VBA in DPWith excerpt from How to Think Like a Computer Scientistby Jeffrey Elkner,Allen B.Downey,and Chris MeyersThings to Consider in ProgrammingVBA in DPProgramming for Designers Let computer to do mundane work and save time/resources Generate(parametric)designs with lots of variations New way of
2、 design,or construction:Looks cool,may earn more?Time to think in a different way Formulate problems Goal Input/Output Driving/Driven Think creatively about solutions Methodology Procedure Represent a solution clearly and accurately Diagram DictationProgramming Language Natural language What people
3、speak English,French,Korean,Formal language Designed for specific applications Mathematical formula,Chemical structure Programming language,of courseVBA Visual Basic for Application VB for Application Integrated into host application Automate processes Visual Basic High level programming language de
4、signed to be learned and used easily One of the programming languages for DP CAT Script,VBA,.NET,VBA is included in a standard DP installationVBA Visual Basic for Application Interpreter CompilerProgram A sequence of instructions specifying computations Instructions Input Output Math Conditional exe
5、cution RepetitionDebugging Fixing errors Errors Syntax error Runtime error Semantic errorGlossary Algorithm A general process for solving a category of problems Exception Another name for a runtime error Script A program stored in a file(usually one that will be interpreted)Variables,Expressions and
6、 StatementsVBA in DPValue and Data Types Value Letter,number,Abc,aaa,1,2,3,Data types String,Integer,Double,Variables A name that refers to a value Variable names aa=1 bb=“names”Keyword and,if,for,while,sub,function,.Statements Statement is a complete instruction that can contain keywords,operators,
7、variables,constants,and expressions.Operators:+,-,*,/,Constant:fixed(constant)variableSet partDocument1=CATIA.ActiveDocument Declaration statements name a variable,constant,or procedure and can also specify a data typeDim partDocument1 As PartDocument Executable statements initiate actionsselect1.Se
8、arch(name=Optimization.MinimumValue,all)FunctionsVBA in DPFunction A named sequence of statements that performs a desired operation.This operation is specified in a function definitionSub mySubName()MsgBox HelloEnd SubSub mySubwithParameter(myParameter)MsgBox myParameterEnd SubSub/Function Sub No re
9、turn value Function With a return valueSub mySubName()MsgBox HelloEnd SubFunction myFunction()myFunction=HiEnd SubSub callFunction()Msgbox myFunctionEnd SubConditional ExecutionVBA in DPConditional Execution Doing different computations depending on(boolean)conditionsIf Then(ElseIf Then.)(Else)End i
10、fSelect Case Case Case Else End SelectBoolean condition A numeric expression or string expression that evaluates to True or False Comparison Operators Used to compare expressions.,=,=,Var1 Var2 And,Or,Not,Xor OperatorVar1 Var3IF Then Else Statement If condition Then statements Else elsestatements Or
11、,you can use the block form syntax:If condition Then statements ElseIf condition-n Then elseifstatements.Else elsestatements End If If A 10 Then A=A-10ElseIf A 10 ThenA=A+10ElseA=0End IfSelect Case Statement Select Case testexpression Case expressionlist-n statements-n.Case Else elsestatements-n End
12、 Select Dim Color,MyVarSub ChangeBackground(Color)MyVar=lcase(Color)Select Case MyVar Case red document.bgColor=red Case green document.bgColor=green Case blue document.bgColor=blue Case Else MsgBox pick another color End SelectEnd SubIterationVBA in DPIteration A repetition of a process For Next Fo
13、r Each Next Do Loop While.WendFor Nextj=0For i=0 to 10j =j+iNextMsgBox The J is&j For i=0 to 10 Step 2j =j+iNextMsgBox The J is now&j For.Next Statement For counter=start To end Step step statements Exit For statements Next For I=1 To 10 For J=1 To 10 For K=1 To 10 .Next NextNextWhile WendCounter=0W
14、hile Counter 10Counter=Counter+1WendMsgBox“Counter is now“&CounterDo.Loop Statement Do While|Until condition statements Exit Do statements LoopDo statements Exit Do statements Loop While|Until condition Do.Loop StatementDo Until DefResp=vbNo MyNum=Int(6*Rnd+1)Generate a random integer between 1 and
15、6.DefResp=MsgBox(MyNum&Do you want another number?,vbYesNo)LoopDim Check,CounterCheck=True:Counter=0 Initialize variables.Do Outer loop.Do While Counter 20 Inner loop.Counter=Counter+1 Increment Counter.If Counter=10 Then If condition is True.Check=False set value of flag to False.Exit Do Exit inner
16、 loop.End If LoopLoop Until Check=False Exit outer loop immediately.ArrayDim students(6)As Integer Object Oriented ProgrammingVBA in DPObject Oriented Programming OOP is all about programming using something called an object OOP consists of designing a bunch of classes most of which will be used as
17、templates to make objects The objects will be used to hold data and will be initialized with constructors and perform useful functions by being asked to run their methodsFrom CS1322 lecture slideWhat is an object?A chunk of memory which contains some data and methods which can operate on the data.So
18、mething that when created may have had special code run to initialize it.Something which has additional behavior defined by methods which can Be passed data via parameters Perform calculations/operations which may Change some of its data Perform some desired operation Return the value of some of its
19、 data Return the results of calculations using both data passed in and data contained in the objectFrom CS1322 lecture slideHow do we define different types of objects?For each different type of object we write a class.New classes may be based on existing classes to allow code reuse A class serves a
20、s a blueprint or template defining how all objects made from this class operate and what data they hold.One class may be used to make one or many objectsFrom CS1322 lecture slideClass:It describes the form of an object.It is a template or blueprint.It specifies data representation,behavior,and inher
21、itance(via variables,methods and parents)Object:It is an instance of a class.It has a unique copy of every non-static variable.(i.e.,the “instance variables”but not the class variables(those labeled with“static”).Naming Conventions:Classes:Identifiers begin with cap letters for each word in the iden
22、tifier,e.g.,class GraduateStudentObjects:Identifiers begins with lower case letter,then caps for other words in identifier,e.g.,graduateStudentPresident Difference between“a class and an object of that class”is analogous to the difference between“a type and a variable of that type”.Key IdeaClasses a
23、nd ObjectsFrom CS1322 lecture slide3 key features Abstract data types Encapsulation of data and behavior Classes as templates used to produce 1 or more instances or objects Inheritance Provides for code-reuse Polymorphism/Dynamic Binding Different objects in the same family may have identically name
24、d methods The language takes care of sorting out the correct method to invoke for usFrom CS1322 lecture slideClass Template for an object.Class.End Class construct Variable Properties Method EventClass Construct Class.End Class Class classnameClass definition End Class Instantiation an object of a c
25、lass Set objc=new classnameClass Variables Class has variables Dim varName1,varName2.Private varName1,varName2.Public varName1,varName2.Dim,Public Open to outside Private Closed to outsideClass Properties Access“wrapper”for private variables Property Get Property Let:value Property Set:referenceClas
展开阅读全文