Private Sub Command1_Click()
Dim a As String, b As String, c As String, strs() As String, strp
Dim d As Long, e As Long, f As Long, l As Long
Dim i As Integer, q As Integer, h As Integer
Dim u As Integer l = 1
strs = Split(List2.List(l - 1), ",")
If UBound(strs) >= 5 Then
a = strs(0)
b = strs(1)
c = strs(2)
d = Val(strs(3))
e = Val(strs(4))
f = Val(strs(5))  End If
For h = MSFlexGrid1.Col To MSFlexGrid1.Col‘从当前空白列开始
 MSFlexGrid1.TextMatrix(0, h) = a & b & c
   
  Next
End Sub
这一段代码,只能处理list当中第一行的数据,现在list里有好几行数据,怎么改才能循环到每个数据,然后依次显示在MSFlexGrid1当前空白列(依次递增)的0行,还有就是a & b & c这个结果只能输出a & b,如果改成a & b & c & a就能输出a & b & c了,为什么最后一个老是不显示
还有就是想添加一个Command2,是我在list当中选中某行后点击,然后结果出现在MSFlexGrid1当前空白列,也就是说这个按键是控制单独的,上面的Command1是控制全部的
这两个该怎么改

解决方案 »

  1.   

    '选每个数
    Dim l As Integer
    For l = List2.ListCount - 1 To 0 Step -1
    If List2.Selected(l) Then strs = Split(List2.List(l - 1), ",") '此句为随便选哪个
    Next l
    List2.Selected(2) = True'为全选
      

  2.   

    Private Sub Command13_Click()
    Dim a As String, b As String, c As String, strs() As String, strp
    Dim d As Long, e As Long, f As Long, l As Long
    Dim i As Integer, q As Integer, h As Integer
    Dim u As Integer
    Dim t As Integer
    For t = List2.ListCount - 1 To 0 Step -1If List2.Selected(t) Then strs = Split(List2.List(t - 1), ",")Next t
    If UBound(strs) >= 5 Then
    a = strs(0)
    b = strs(1)
    c = strs(2)
    d = Val(strs(3))
    e = Val(strs(4))
    f = Val(strs(5))  End If
    For h = MSFlexGrid1.Col To MSFlexGrid1.Col
     MSFlexGrid1.TextMatrix(0, h) = a & b & c
       
      Next
      
    End Sub
    这么改完list第一行的不读取啊,选择第二行,竟然读取的是第一行,选第3行读的竟然是第二行的数据
      

  3.   

    If List2.Selected(t) Then strs = Split(List2.List(t), ",")