设为首页 加入收藏

TOP

MicroStation VBA基础(一)
2017-10-11 18:12:33 】 浏览:1589
Tags:MicroStation VBA 基础

实习笔记1

2016年8月1日

14:12

Option Explicit

缺省情况下,如果使用一个没有声明的变量,它将继承“Variant”类型。在模块、窗体和类的通用声明区使用“OptionExplicit”能强制我们必须声明变量后才能使用变量

Sample:

Option Explicit

Sub test()

X = 5

End Sub

 

在通用声明区声明了“Option Explicit”。当试着去运行上述test宏时将得到一个错误

本章回顾

1.在过程、函数或用户窗体事件中写代码

2.在过程和函数中利用必须的和可选的参数

3.函数可返回值、数组、类型和对象

4.在过程和函数中,如果参数声明为“ByRef”,则可以改变作为参数传递进来的变量。把参数声明为“ByVal”将保持变量不变

4.能在过程、函数和事件中或者在通用声明区内声明变量。这些变量的范围依赖于它们在何处被声明以及声明中所用的关键字

第六章 变量

Option Explicit

Sub tst()

TTT = 5

MsgBox TTT

End Sub

'整型

Dim PageNumber As Integer

PageNumber = 84

'长整型

Dim MySalary As Long

MySalary = 123456

'双精度型

Dim HourToLearnVBA As Double

HourToLearnVBA = 36.25

Sub VariableTestC()

Dim N As Double

N = 1.23456789012346

N = 12345678901234.6

End Sub

'布尔类型

Dim ICanLearnThis As Boolean

ICanLearnThis = True

'日期型

Dim XMReleaseDate As Date

XMReleaseDate = "5/19/2006 8:00:00 AM"

'字符型

Dim MYLevelName As String

MYLevelName = "utilElectricity"

'对象型

Dim MyExcelApp As Object

Set MyExcelApp = GetObject(, "Excel.Application")

'Variant

Dim PointArray As Variant

'MicroStation特有的变量类型

'Application(应用)

Dim MSAPP As Application

Set MSAPP = Application

'ActiveDesignFile当前设计文件

'ActiveModelReference当前模型参考

'ActiveSettings 当前设置

'VBProject object & attributes 对象以及属性

'UserName用户名

'取得左、顶、宽和高属性

'DesignFile设计文件

Dim MyDGN As DesignFile

Set MyDGN = Application.ActiveDesignFile

'Author 作者,Client客户,Comments注释,Company公司,KeyWords关键字,Manager管理者,Subject主题,Title标题

'FormatMajorVersion 格式主版本 FormatMinorVersion格式次版本

'Levels层, Models模型, Name 名称,Path 路径

'ModelReference 模型参考

Dim MyModel As ModelReference

Set MyModel = Application.ActiveModelReference

'Level 层

Dim MyLevel As Level

Set MyLevel = Application.ActiveDesignFile.Levels(1)

'Description 描述, ElementColor元素颜色,ElementLineStyle元素线性,ElementLineWeight元素线宽,IsActive是否激活,IsDisplayed是否显示

'IsFrozen是否冻结,IsLocked是否锁定,Name名字,Number层号,Plot光栅绘图

'LineElement线元素

Dim MyLine As Application

Set MyLine = Application.CreateLineElement2(Nothing, Point3dFromXYZ(0, 0, 0), Point3dFromXYZ(4, 5, 6))

Application.ActiveModelReference.AddElement MyLine

'EllipseElement椭圆元素

Dim MyCircle As EllipseElement

Dim RotMatrix As Matrix3d

Set MyCircle = CreateEllipseElement2(Nothing, Point3dFromXYZ(0, 0, 0), 1.5, 1.5, RotMatrix)

Application.ActiveModelReference.AddElement MyCircle

'ArcElement 弧元素

Dim MyArc As ArcElement

Dim RotMatrix As Matrix3d

Set MyArc = CreateArcElement2(Nothing, Point3dFromXYZ(0, 0, 0), 1.75, 1.75, RotMatrix, Radians(45), Radiands(90))

Application.ActiveModelReference.AddElement MyArc

'TextElement文本元素

Dim MyText As TextElement

Dim RotMatrix As Matrix3d

Set MyText = CreateTextElement1(Nothing, "MicroStation VBA", Point3dFromXYZ(0, 0, 0), RotMatrix)

Application.ActiveModelReference.AddElement MyText

'赋值和设置对象

Dim LevelName As String

LevelName = "Element"

Dim EasementLevel As Level

Set EasementLevel = ActiveDesignFile.AddNewLevel(LevelName)

Dim StartPoint(0 To 2) As Double

StartPoi
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇pip和easy_install使用方式 下一篇[PE格式分析] 3.IMAGE_NT_HEADER

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目