请教高手,在使用GETREAL命令时怎样设置默认的数值???
<p>Dim DimVolume as Double </p><p>DimVolume=3.5</p><p>DimVolume = ThisDrawing.Utility.GetReal()<br/></p><p>如上,想把DimVolume的初始值作为一个默认值,不用输入,直接回车或右键就通过...</p> <p>Sub test()<br/> Dim DimVolume As Double<br/> <br/> On Error Resume Next<br/> DimVolume = 3.5<br/> DimVolume = ThisDrawing.Utility.GetReal(vbCr & "请输入一个实数<" & DimVolume & ">:")<br/> If Err Then Err.Clear<br/>End Sub</p><p>切记:错误处理在VBA里是一个基本心法。</p> <p>谢谢楼上的,</p><p>可是如果通过错误处理的会,那按ESC键就不能取消命令了</p><p>或者如果在处理错误的同时,能够分清是那个键(ESC ENTER 右键 空格),那就没什么问题了</p> <p>Public Const escape = &H1B<br/>Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer</p><p>'判断按键<br/>Public Function checkkey(lngkey As Long) As Double<br/> If GetAsyncKeyState(lngkey) Then<br/> checkkey = True<br/> Else<br/> checkkey = False<br/> End If<br/>End Function</p><p>Sub test()<br/> Dim DimVolume As Double<br/> <br/> On Error Resume Next<br/> DimVolume = 3.5<br/> DimVolume = ThisDrawing.Utility.GetReal(vbCr & "请输入一个实数<" & DimVolume & ">:")</p><p> If checkkey(escape) = True Then Exit Sub<br/> If Err Then Err.Clear<br/>End Sub</p><p></p> 真是非常感谢! 别客气~互相帮助!
页:
[1]