三个vba开发的问题
问题1:<BR>distance=thisdrawing.utility.getinteger("默认值为10")<BR>如果不输入数字,直接按enter<BR>会出现“需要整数值,或选项关键字”的提示<BR>请问:如何使得按enter后,使用自己的默认值继续往下执行问题2:<BR>GetEntity、GetInteger、GetKeyword执行时,按Esc,如何跳出下面的程序,重回AutoCAD命令界面(即要求输入时,如我想退出,如何办?)。但是,输入其他类型数据,仍然提示错误,要求重新输入,只有Esc可以退出程序?
问题3:<BR>enAng = ThisDrawing.Utility.AngleFromXAxis(ThisDrawing.Utility.GetPoint, ThisDrawing.Utility.GetPoint)<BR>该函数执行时,返回的角度不是和x轴的夹角,请问是什么原因????
请大家多多指点
大家帮忙啊!!!
此外,有没有用vba开发的,计算两个圆交点的程序段啊???还有圆与直线相交计算交点的程序段啊??? 尝试捕获错误,获得错误号,然后针对错误号处理。 1.Sub Example_GetInt()
On Error Resume Next
ThisDrawing.Utility.InitializeUserInput 128
Dim returnInt As Integer
returnInt = ThisDrawing.Utility.GetInteger(vbCr & "请输入数值<10>: ")
If Err Then
If StrComp(Err.Number, -2145320928, 1) = 0 Then
Dim inputString As String
Err.Clear
inputString = ThisDrawing.Utility.GetInput
If inputString = "" Then
MsgBox "你输入的是默认值10", , "明经通道VBA示例"
returnInt = 10
Else
MsgBox "你输入了关键字为: " & inputString
End If
Else
MsgBox "出错了: " & Err.Description
Err.Clear
End If
Else
MsgBox "输入的整数为: " & returnInt, , "明经通道VBA示例"
End If
End Sub 1、2是同一个问题
3、是与X轴的夹角
另外,IntersectWith函数 这是我的一个数据输入的子程序,对你的问题有帮助
Public Function Fun图形数据输入(TmpMsg As String, WhatType As CadInputType, HasNothing As Boolean) As Variant<BR> Dim xTmp As Variant, DefVal As String, i As Integer, j As Integer<BR> i = InStr(TmpMsg, "<"): j = InStr(TmpMsg, ">")<BR> If i > 0 And j > 0 Then DefVal = Mid(TmpMsg, i + 1, j - i - 1)<BR> On Error Resume Next<BR>Aa:<BR> Select Case WhatType<BR> Case 1 'inputAngle = 1<BR> xTmp = -99999<BR> xTmp = ThisDrawing.Utility.GetAngle(, TmpMsg)<BR> If xTmp = -99999 Then If Not HasNothing Then GoTo Aa Else xTmp = IIf(IsNumeric(DefVal), CInt(DefVal), 0)<BR> Case 2 'inputDistance = 2<BR> xTmp = -99999<BR> xTmp = ThisDrawing.Utility.GetDistance(, TmpMsg)<BR> If xTmp = -99999 Then If Not HasNothing Then GoTo Aa Else xTmp = IIf(IsNumeric(DefVal), CDbl(DefVal), 0)<BR> Case 3 'inputInteger = 3<BR> xTmp = -99999<BR> xTmp = ThisDrawing.Utility.GetInteger(TmpMsg)<BR> If xTmp = -99999 Then If Not HasNothing Then GoTo Aa Else xTmp = IIf(IsNumeric(DefVal), CInt(DefVal), 0)<BR> Case 4 'inputKeyword = 4<BR> xTmp = ThisDrawing.Utility.GetKeyword(TmpMsg)<BR> 'If xTmp Is Empty And Not HasNothing Then GoTo Aa<BR> Case 5 'inputPoint = 5<BR> Dim xD(2) As Double, sPnt As Variant, tD() As Double<BR> xD(0) = -99999: xD(1) = -99999: ReDim tD(2)<BR> xTmp = xD<BR> If Not DefVal = "" Then Call PntStrToDat(DefVal, tD)<BR> ReDim Preserve tD(2): sPnt = tD<BR> Beep<BR> TmpMsg = Replace(TmpMsg, "<" + DefVal + ">", "")<BR> xTmp = ThisDrawing.Utility.GetPoint(sPnt, TmpMsg)<BR> If xTmp(0) = -99999 And xTmp(1) = -99999 Then If Not HasNothing Then GoTo Aa<BR> Case 6 'inputReal = 6<BR> xTmp = -99999<BR> xTmp = ThisDrawing.Utility.GetReal(TmpMsg)<BR> If xTmp = -99999 Then If Not HasNothing Then GoTo Aa Else xTmp = DefVal<BR> Case 7 'inputString = 7<BR> xTmp = ThisDrawing.Utility.GetString(0, TmpMsg)<BR> If xTmp = "" Then If Not HasNothing Then GoTo Aa Else xTmp = DefVal<BR> End Select<BR> Fun图形数据输入 = xTmp<BR>End Function 太感谢大家了!!!!!
我会试一下的!!!!
另外为什么网页保存不了啊??? 问题1的解决:
我在distance=thisdrawing.utility.getinteger("默认值为10")前面用默认值给distance赋值,然后利用on error resume next的忽略错误功能继续执行...这个方法还可以..当然,用大家的扑捉错误也可以,不过,,if语句嵌套的太多了(我前面也用了好多if)
问题2的又一个疑问:
GetEntity函数:当这个函数等待用户选择时,按esc和选不中对象的err.number数值是一样的,,,真是不晓得,如何对按esc和选不中对象分别编写不同的错误处理程序了???大家知道吗???????
问题3的解释:
AngleFromXAxis返回弧度值,而不是角度.......
另外,想问大家,弧度的起点是x轴,请问,用什么去判断到底是顺时针为正,还是逆时针为正????????????????
页:
[1]