在VBA CAD二次开发中,sub语句里能嵌套function函数吗?运行程序时提醒我没有End sub 呢?下边是我的程序 10

PrivateSubCommandButton1_Click()PrivateFunctionAddLWPlineArc(ByValptCenAsVariant,ByVa... Private Sub CommandButton1_Click()Private Function AddLWPlineArc(ByVal ptCen As Variant, ByVal radius As Double, ByVal angleSt As Double, ByVal angleEn As Double, ByVal width As Double) As AcadLWPolyline
Dim objPline As AcadLWPolyline
Dim ptCen(0 To 1) As Variant
Dim radius As Double
Dim angleSt As Double
Dim angleEn As Double
Dim width As Double
ptCen(0) = Val(TextBox8.Text)
ptCen(1) = Val(TextBox7.Text)
radius = Val(TextBox3.Text)
angleSt = Val(TextBox4.Text)
angleEn = Val(TextBox5.Text)
wdth = Val(TextBox6.Text)
Dim ptArr(0 To 3) As Double
ptArr(0) = ptCen(0) + radius * Cos(angleSt)
ptArr(1) = ptCen(1) + radius * Sin(angleSt)
ptArr(2) = ptCen(0) + radius * Cos(angleEn)
ptArr(3) = ptCen(1) + radius * Sin(angleEn)
Set objPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(ptArr)
objPline.ConstantWidth = width
If angleEn < angleSt Then
angleSt = angleSt - 8 * Ant(1)
End If
objPline.SetBulge 0, Tan((angleEn - angleSt) / 4)
objPline.SetBulge 1, 0
objPline.Update
Set AddLWPlineArc = objPline
End Function
要加上end sub 时发现end function只能在最后一行,end sub加哪啊
展开
 我来答
yangsanmyth
2013-04-25 · TA获得超过573个赞
知道小有建树答主
回答量:396
采纳率:0%
帮助的人:297万
展开全部
不能嵌套,只能引用。可以把函数写在过程下面,然后在SUB过程中使用此函数。
更多追问追答
追问
能不能帮我改改这个程序,写在过程下面是什么意思,初学者,求指导
追答

你这个要函数作什么,不需要函数啊,程序改为:

Private Sub CommandButton1_Click()
Dim objPline As AcadLWPolyline
Dim ptCen(0 To 1) As Variant
Dim radius As Double
Dim angleSt As Double
Dim angleEn As Double
Dim width As Double
ptCen(0) = Val(TextBox8.Text)
ptCen(1) = Val(TextBox7.Text)
radius = Val(TextBox3.Text)
angleSt = Val(TextBox4.Text)
angleEn = Val(TextBox5.Text)
width = Val(TextBox6.Text)
Dim ptArr(0 To 3) As Double
ptArr(0) = ptCen(0) + radius * Cos(angleSt)
ptArr(1) = ptCen(1) + radius * Sin(angleSt)
ptArr(2) = ptCen(0) + radius * Cos(angleEn)
ptArr(3) = ptCen(1) + radius * Sin(angleEn)
Set objPline = ThisDrawing.ModelSpace.AddLightWeightPolyline(ptArr)
objPline.ConstantWidth = width
If angleEn < angleSt Then
angleSt = angleSt - 8 * Ant(1)
End If
objPline.SetBulge 0, Tan((angleEn - angleSt) / 4)
objPline.SetBulge 1, 0
objPline.Update
End sub

试试

视体翼度说06
2013-05-08
知道答主
回答量:63
采纳率:0%
帮助的人:17万
展开全部
一般和Private Sub 对应 你加在最后
来自:求助得到的回答
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式