明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3354|回复: 9

cad 帮助文件中的Example_InitializeUserInput例子,为何不行?

[复制链接]
发表于 2003-11-23 16:40:00 | 显示全部楼层 |阅读模式
在什么情况下
StrComp(Err.Description, "User input is a keyword", 1) = 0 才成立
???
我把keywordList = "Keyword1 Keyword2"改成keywordList = “Yes Not”
输入y的时候StrComp(Err.Description, "User input is a keyword", 1) = 0
的条件也不成立。何解??

Sub Example_InitializeUserInput()
    ' This example prompts for user input of a point. By using the
    ' InitializeUserInput method to define a keyword list, it can also
    ' return keywords entered by the user.
   
    On Error Resume Next
   
    ' Define the valid keywords
    Dim keywordList As String
    keywordList = "Keyword1 Keyword2"
   
    ' Call InitializeUserInput to setup the keywords

    ThisDrawing.Utility.InitializeUserInput 128, keywordList
   
    ' Get the user input
    Dim returnPnt As Variant
    returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point(Keyword1, Keyword2): ")
    If Err Then
         If StrComp(Err.Description, "User input is a keyword", 1) = 0 Then
         ' One of the keywords was entered
             Dim inputString As String

             Err.Clear
             inputString = ThisDrawing.Utility.GetInput
             MsgBox "You entered the keyword: " & inputString
         Else
             MsgBox "Error selecting the point: " & Err.Description
             Err.Clear
         End If
    Else
        ' Display point coordinates
        MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetInput Example"

    End If
   
End Sub
发表于 2003-11-23 20:02:00 | 显示全部楼层
一般情况下不要使用Err.Description来得到出错信息内容,最好使用Err.Number来得到出错编号。
你可以使用debug.print err.number先看看什么样的情况下出什么样的号码,再完善程序。
 楼主| 发表于 2003-11-23 23:17:00 | 显示全部楼层
最主要几种错误的错误代码都是一样。怎么办呢?
发表于 2003-11-24 07:34:00 | 显示全部楼层
Sub Example_InitializeUserInput()
    ' This example prompts for user input of a point. By using the
    ' InitializeUserInput method to define a keyword list, it can also
    ' return keywords entered by the user.
   
    On Error Resume Next
   
    ' Define the valid keywords
    Dim keywordList As String
    keywordList = "Yes No"
   
    ' Call InitializeUserInput to setup the keywords

    ThisDrawing.Utility.InitializeUserInput 128, keywordList
   
    ' Get the user input
    Dim returnPnt As Variant
    returnPnt = ThisDrawing.Utility.GetPoint(, "选择点或输入[是(Y)/否(N)]<是>: ")
    If Err Then
         If Err.Number = -2145320928 Then
         ' One of the keywords was entered
             Dim inputString As String
             Err.Clear
             inputString = ThisDrawing.Utility.GetInput
             If inputString = "" Then
                MsgBox "你选择了默认的选项"
            Else
                MsgBox "你输入的关键字为: " & inputString
            End If
         Else
             MsgBox "选择点时出错: " & Err.Description
             Err.Clear
         End If
    Else
        ' Display point coordinates
        MsgBox "选择的点坐标为: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "明经通道VBA示例"

    End If
   
End Sub
 楼主| 发表于 2003-11-24 09:37:00 | 显示全部楼层
我调试的时候输入Y,出错“选择点时出错:方法getpoint作用于iacadutility时出错”
 楼主| 发表于 2003-11-24 10:12:00 | 显示全部楼层
我把错误代码改为2147467259,就可以了,不过每次用按空格(默认)的时候,总是显示上一次的值
发表于 2003-11-24 12:54:00 | 显示全部楼层
按空格键返回默认值要这样设置:
If inputString = "" Then
    inputString="Yes"
End If
 楼主| 发表于 2003-11-24 14:14:00 | 显示全部楼层
但不知道怎么回事,我按空格的时候条件 If inputString = "" Then 不成立!!奇怪:(
发表于 2003-11-25 10:37:00 | 显示全部楼层
在初始化时不允许按空格,Bits参数改为127,如下:
ThisDrawing.Utility.InitializeUserInput 127, keywordList
发表于 2003-11-25 10:41:00 | 显示全部楼层
本人觉得这可能是autocad2002中的一个bug.你打上sp1再试试.我没试过.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-25 00:36 , Processed in 0.186261 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表