suminder 发表于 2020-12-17 09:13:43

写了一个阵列函数,可是老是提示要求对象,是咋回事?

Public Function InArry(ByVal n1 As Variant, ByVal n2 As Variant, ByVal u1 As Variant, ByVal u2 As Variant) As AcadEntity
    Dim SSet As AcadSelectionSet
    Dim element As AcadEntity
    Set SSet = createSSet("mySelectionSet")
    SSet.SelectOnScreen
    For Each element In SSet
    Set InArry = element.ArrayRectangular(n1, n2, 1, u1, u2, 1)
    Next
End Function


给4个参数赋完值,运行时图形是阵列完了,但是老是出“要求对象”错误是哪里有问题

谢谢大佬

suminder 发表于 2020-12-17 09:28:49

mikewolf2k 发表于 2020-12-17 09:41:52

看帮助看帮助看帮助!!!
阵列完了是多个对象吧,把多个对象赋值给一个对象,是什么操作???

suminder 发表于 2020-12-17 10:55:27

mikewolf2k 发表于 2020-12-17 09:41
看帮助看帮助看帮助!!!
阵列完了是多个对象吧,把多个对象赋值给一个对象,是什么操作???

谢谢大佬,我也正在学:'(,这种多个对象要怎么处理才行吖:'(

mikewolf2k 发表于 2020-12-17 11:11:05

Public Function InArry(ByVal n1 As Variant, ByVal n2 As Variant, ByVal u1 As Variant, ByVal u2 As Variant) As Variant

suminder 发表于 2020-12-17 13:33:01

mikewolf2k 发表于 2020-12-17 11:11
Public Function InArry(ByVal n1 As Variant, ByVal n2 As Variant, ByVal u1 As Variant, ByVal u2 As Va ...

大佬,还是不行,“类型不匹配”:'(

suminder 发表于 2020-12-17 13:35:11

像这种多个对象,应该怎么存放才行啊:loveliness:

mikewolf2k 发表于 2020-12-17 13:48:20

Sub bbb()
    Dim AA
    AA = InArry(2, 2, 2, 2)
End Sub
Public Function InArry(ByVal n1 As Variant, ByVal n2 As Variant, ByVal u1 As Variant, ByVal u2 As Variant) As Variant
    Dim SSet As AcadSelectionSet
    Dim element As AcadEntity
    Set SSet = createSSet("mySelectionSet")
    SSet.SelectOnScreen
    For Each element In SSet
    InArry = element.ArrayRectangular(n1, n2, 1, u1, u2, 1)
    Next
End Function

suminder 发表于 2020-12-17 14:47:42

mikewolf2k 发表于 2020-12-17 13:48
Sub bbb()
    Dim AA
    AA = InArry(2, 2, 2, 2)


谢谢大佬!不知道为什么在原来工程就会“类型不匹配”,新建一个工程放里面就可以运行:L
还有 原来还可以声明变量可以不声明类型的

mikewolf2k 发表于 2020-12-17 14:56:54

suminder 发表于 2020-12-17 14:47
谢谢大佬!不知道为什么在原来工程就会“类型不匹配”,新建一个工程放里面就可以运行
还有 原来还可 ...

不声明就是Variant
页: [1] 2
查看完整版本: 写了一个阵列函数,可是老是提示要求对象,是咋回事?