本帖最后由 VB_XP 于 2011-04-16 11:22:33 编辑

解决方案 »

  1.   

    dim i as inter
    dim j as interfor i=0 to 11
       for j=0 to i+1
           a(i)=a(i)+Grid1.Column(j).Width
       next
    next思路是这样的,代码自已整理一下,应该可以!
      

  2.   

     
    qiwen1530 不对哦 所赋值不正确 赋值后 无法退出
      

  3.   

    你的意思是,a(0)=b(0)+b(1),a(1)=a(0)+b(2),a(2)=a(1)+b(3)……?
      

  4.   

    grid控件是一个表格同msflexgrid一样 
    我的意思是
    a(0)=Grid1.Column(0).Width+Grid1.Column(1).Width
    a(1)=a(0)+Grid1.Column(2).Width
    a(2)=a(1)+Grid1.Column(3).Width
    a(3)=a(2)+Grid1.Column(4).Width
    ......
    a(11)=a(10)+Grid1.Column(12).Width就是加上上已列的列宽值
      

  5.   

    当然还要当a(0),a(1)....a(11)都有值时候,就退出给他们赋值的操作
      

  6.   

    标准答案来了Private Sub Command1_Click()
    Dim a(12) As Long
    Dim i As Long, j As Long
    With Grid1
    a(0) = Grid1.Column(0).Width + Grid1.Column(1).Width
    Me.Caption = Me.Caption & ",a(0)=" & a(0)
    For i = 1 To 11
        a(i) = a(i - 1) + .Column(i + 1).Width
        Me.Caption = Me.Caption & ",a(" & i & ")=" & a(i)
    Next
    End With
    End Sub