1. 
Const n = 10  
Dim a(1 To n + 1) As New Collection 
'请问 这个n 怎么能让用户输入  产生用户输入数的Collection 2. 
a.count 为什么不行。。就是得到当前的Collection 个数 
 
 

解决方案 »

  1.   

    1、用InputBox 函数输入n:  n=InputBox(“请输入整数:”)
    2、用for each...next枚举
      

  2.   

    1.form上加text,用户输入在text框中,text.text取值或用input()2.ubound(a)
      

  3.   

    1 没看懂啥意思
    2 用a.ubound
      

  4.   

    Private Sub Command1_Click()
        Dim n As Long
        Dim a() As Collection
        
        n = Val(Text1)
        If n < 0 Then Exit Sub
        
        ReDim a(1 To n + 1) As Collection '数组 As New 没用,要逐个新建对象
        Debug.Print UBound(a) - LBound(a) + 1 ‘这样计算数组个数
    End Sub
      

  5.   

    Dim a(1 To n + 1) As New Collection本身就不符合VB语法
      

  6.   

    要想输入n,我想不能用const定义吧
      

  7.   

    不明白想干吗?
    从字面意思看,是要声明一个集合类型的数组,并得到数组的个数
    N的输入很简单,加一个TextBox或用InputBox都可以
    得到数组个数一般来说用ubound,但因为你的数组的下限不是默认的0
    那就得计算了    Dim a() As Collection
        Dim n As Integer
        n = InputBox("请输入整数:")
        ReDim a(1 To n + 1) As Collection
        Debug.Print UBound(a) - LBound(a) + 1