首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

如何将窗体式的代码转到模块中运行啊

2012-02-13 
怎么将窗体式的代码转到模块中运行啊?Private Sub Label2_Click()Dim ColPrivate Sub CheckBox1_Click()If

怎么将窗体式的代码转到模块中运行啊?
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


以上代码是在窗体中运行的,现在我想改到模块中运行,应该怎么做?

[解决办法]
你可以无满意结贴,谢谢。分又不是钱。
[解决办法]
自已解决了,比别人给你解决了,应该更有成就感,分只要你每顶顶帖子就有了。

热点排行