zzcctt 发表于 2007-5-22 18:01:00

请教高手,在使用GETREAL命令时怎样设置默认的数值???

<p>Dim DimVolume as&nbsp;Double&nbsp;&nbsp;&nbsp; </p><p>DimVolume=3.5</p><p>DimVolume = ThisDrawing.Utility.GetReal()<br/></p><p>如上,想把DimVolume的初始值作为一个默认值,不用输入,直接回车或右键就通过...</p>

laoliu09 发表于 2007-5-22 20:06:00

<p>Sub test()<br/>&nbsp;&nbsp;&nbsp; Dim DimVolume As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; DimVolume = 3.5<br/>&nbsp;&nbsp;&nbsp; DimVolume = ThisDrawing.Utility.GetReal(vbCr &amp; "请输入一个实数&lt;" &amp; DimVolume &amp; "&gt;:")<br/>&nbsp;&nbsp;&nbsp; If Err Then Err.Clear<br/>End Sub</p><p>切记:错误处理在VBA里是一个基本心法。</p>

zzcctt 发表于 2007-5-23 08:05:00

<p>谢谢楼上的,</p><p>可是如果通过错误处理的会,那按ESC键就不能取消命令了</p><p>或者如果在处理错误的同时,能够分清是那个键(ESC ENTER 右键 空格),那就没什么问题了</p>

laoliu09 发表于 2007-5-23 10:23:00

<p>Public Const escape = &amp;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/>&nbsp; If GetAsyncKeyState(lngkey) Then<br/>&nbsp;&nbsp;&nbsp; checkkey = True<br/>&nbsp; Else<br/>&nbsp;&nbsp;&nbsp; checkkey = False<br/>&nbsp; End If<br/>End Function</p><p>Sub test()<br/>&nbsp;&nbsp;&nbsp; Dim DimVolume As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; DimVolume = 3.5<br/>&nbsp;&nbsp;&nbsp; DimVolume = ThisDrawing.Utility.GetReal(vbCr &amp; "请输入一个实数&lt;" &amp; DimVolume &amp; "&gt;:")</p><p>&nbsp;&nbsp;&nbsp; If checkkey(escape) = True Then Exit Sub<br/>&nbsp;&nbsp;&nbsp; If Err Then Err.Clear<br/>End Sub</p><p></p>

zzcctt 发表于 2007-5-23 22:29:00

真是非常感谢!

laoliu09 发表于 2007-5-23 23:33:00

别客气~互相帮助!
页: [1]
查看完整版本: 请教高手,在使用GETREAL命令时怎样设置默认的数值???