乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 161|回复: 9

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

[复制链接]

28

主题

117

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 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
回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 2003-11-23 20:02:00 | 显示全部楼层
一般情况下不要使用Err.Description来得到出错信息内容,最好使用Err.Number来得到出错编号。
你可以使用debug.print err.number先看看什么样的情况下出什么样的号码,再完善程序。
回复

使用道具 举报

28

主题

117

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 2003-11-23 23:17:00 | 显示全部楼层
最主要几种错误的错误代码都是一样。怎么办呢?
回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 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
回复

使用道具 举报

28

主题

117

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 2003-11-24 09:37:00 | 显示全部楼层
我调试的时候输入Y,出错“选择点时出错:方法getpoint作用于iacadutility时出错”
回复

使用道具 举报

28

主题

117

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 2003-11-24 10:12:00 | 显示全部楼层
我把错误代码改为2147467259,就可以了,不过每次用按空格(默认)的时候,总是显示上一次的值
回复

使用道具 举报

26

主题

589

帖子

10

银币

中流砥柱

Rank: 25

铜币
693
发表于 2003-11-24 12:54:00 | 显示全部楼层
按空格键返回默认值要这样设置:
If inputString = "" Then
    inputString="Yes"
End If
回复

使用道具 举报

28

主题

117

帖子

4

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
229
发表于 2003-11-24 14:14:00 | 显示全部楼层
但不知道怎么回事,我按空格的时候条件 If inputString = "" Then 不成立!!奇怪:(
回复

使用道具 举报

2

主题

21

帖子

2

银币

初来乍到

Rank: 1

铜币
29
发表于 2003-11-25 10:37:00 | 显示全部楼层
在初始化时不允许按空格,Bits参数改为127,如下:
ThisDrawing.Utility.InitializeUserInput 127, keywordList
回复

使用道具 举报

2

主题

21

帖子

2

银币

初来乍到

Rank: 1

铜币
29
发表于 2003-11-25 10:41:00 | 显示全部楼层
本人觉得这可能是autocad2002中的一个bug.你打上sp1再试试.我没试过.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-29 12:31 , Processed in 1.428929 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表