怎么将窗体式的代码转到模块中运行啊?
时间:2011-09-21
来源:互联网
Private Sub Label2_Click()
Dim Col
Private Sub CheckBox1_Click()
If CheckBox1 Then
Label1.Caption = "拾取颜色"
On Error Resume Next
Dim Sset As AcadSelectionSet '声明选择集
Set Sset = ThisDrawing.SelectionSets.Add("SS1") 'set选择集
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "LWPolyline,line" '只可选择多段线和直线
Sset.SelectOnScreen FilterType, FilterData '从屏幕选择对象
For Each ent In Sset '遍历所选择集中对象
Col = ent.color
Exit For
Next
ThisDrawing.SelectionSets("SS1").Delete
Set Sset = Nothing
Label1.Caption = "选择当前颜色"
Else
Label1.Caption = "选择所有颜色"
End If
End Sub
Private Sub CommandButton1_Click()
Dim Hj As String
'Set Exc = GetObject("d:\test\计算过程.XLS")
'Exc.Application.Visible = True
'MsgBox Exc.Workbooks.Count
On Error Resume Next
CommandButton1.Enabled = False
Dim Sset As AcadSelectionSet '声明选择集
Set Sset = ThisDrawing.SelectionSets.Add("SS1") 'set选择集
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "LWPolyline,line" '只可选择多段线和直线
Sset.SelectOnScreen FilterType, FilterData '从屏幕选择对象
For Each ent In Sset '遍历所选择集中对象
If CheckBox1 Then
If ent.color = Col Then
If Hj = "" Then Hj = Round(ent.Length / 1000, 2) Else Hj = Hj & "+" & Round(ent.Length / 1000, 2)
End If
Else
If Hj = "" Then Hj = Round(ent.Length / 1000, 2) Else Hj = Hj & "+" & Round(ent.Length / 1000, 2)
End If
Next
TextBox1.Text = Hj
TextBox2.Text = Evaluate(FDun(Hj))
ThisDrawing.SelectionSets("SS1").Delete
Set Sset = Nothing
End Sub
Private Sub CommandButton2_Click()
TextBox1.SelStart = 0
TextBox1.SelLength = TextBox1.TextLength
TextBox1.Copy
CommandButton1.Enabled = True
End Sub
Public Function FDun(S)
i = 219
Do Until Len(S) < 255
i = i + 1
If i = 220 Then
Do Until Mid(S, i + 1, 1) = "+": i = i + 1: Loop
S = Evaluate(Left(S, i)) & Right(S, Len(S) - i)
i = 219
End If
Loop
FDun = Evaluate(S)
End Function
以上代码是在窗体中运行的,现在我想改到模块中运行,应该怎么做?
Dim Col
Private Sub CheckBox1_Click()
If CheckBox1 Then
Label1.Caption = "拾取颜色"
On Error Resume Next
Dim Sset As AcadSelectionSet '声明选择集
Set Sset = ThisDrawing.SelectionSets.Add("SS1") 'set选择集
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "LWPolyline,line" '只可选择多段线和直线
Sset.SelectOnScreen FilterType, FilterData '从屏幕选择对象
For Each ent In Sset '遍历所选择集中对象
Col = ent.color
Exit For
Next
ThisDrawing.SelectionSets("SS1").Delete
Set Sset = Nothing
Label1.Caption = "选择当前颜色"
Else
Label1.Caption = "选择所有颜色"
End If
End Sub
Private Sub CommandButton1_Click()
Dim Hj As String
'Set Exc = GetObject("d:\test\计算过程.XLS")
'Exc.Application.Visible = True
'MsgBox Exc.Workbooks.Count
On Error Resume Next
CommandButton1.Enabled = False
Dim Sset As AcadSelectionSet '声明选择集
Set Sset = ThisDrawing.SelectionSets.Add("SS1") 'set选择集
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "LWPolyline,line" '只可选择多段线和直线
Sset.SelectOnScreen FilterType, FilterData '从屏幕选择对象
For Each ent In Sset '遍历所选择集中对象
If CheckBox1 Then
If ent.color = Col Then
If Hj = "" Then Hj = Round(ent.Length / 1000, 2) Else Hj = Hj & "+" & Round(ent.Length / 1000, 2)
End If
Else
If Hj = "" Then Hj = Round(ent.Length / 1000, 2) Else Hj = Hj & "+" & Round(ent.Length / 1000, 2)
End If
Next
TextBox1.Text = Hj
TextBox2.Text = Evaluate(FDun(Hj))
ThisDrawing.SelectionSets("SS1").Delete
Set Sset = Nothing
End Sub
Private Sub CommandButton2_Click()
TextBox1.SelStart = 0
TextBox1.SelLength = TextBox1.TextLength
TextBox1.Copy
CommandButton1.Enabled = True
End Sub
Public Function FDun(S)
i = 219
Do Until Len(S) < 255
i = i + 1
If i = 220 Then
Do Until Mid(S, i + 1, 1) = "+": i = i + 1: Loop
S = Evaluate(Left(S, i)) & Right(S, Len(S) - i)
i = 219
End If
Loop
FDun = Evaluate(S)
End Function
以上代码是在窗体中运行的,现在我想改到模块中运行,应该怎么做?
作者: dcl1214 发布时间: 2011-09-21
我自己已经解决了,运行正常,又要将分儿给别人了,郁闷!
作者: dcl1214 发布时间: 2011-09-22
你可以无满意结贴,谢谢。分又不是钱。
作者: ChoasRules 发布时间: 2011-09-22
自已解决了,比别人给你解决了,应该更有成就感,分只要你每顶顶帖子就有了。
作者: chinaboyzyq 发布时间: 2011-09-22
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28