VB 看看这个数据分组代码怎么写?(可行的话再追加15分)

[复制链接]
查看11 | 回复1 | 2007-8-4 17:02:49 | 显示全部楼层 |阅读模式
我的代码又重新改了一下Text1是原始数据Text2是排列后的结果Command1是执行分组的按钮注意:Text1.MultiLine = TrueText1.ScrollBars = 2Text2.MultiLine = TrueText2.ScrollBars = 2要预先设置下面是代码Private Sub Command1_click()Text2.Text = ""Open "c:\a.txt" For Output As #1Print #1, Text1.TextClose #1Dim a As StringDim b() As String, i As IntegerOpen "c:\a.txt" For Input As #1Do While Not EOF(1)Line Input #1, aReDim Preserve b(i) As Stringb(i) = b(i) & ai = i + 1LoopClose #1Dim j As IntegerFor j = 0 To UBound(b) - 5 '5代表每组5条数据Text2.Text = Text2.Text & "第" & j + 1 & "组" & Chr(13) & Chr(10)For i = j To j + 4 '4代表每组4+1条数据Text2.Text = Text2.Text & b(i) & Chr(13) & Chr(10)Next iNext jKill "c:\a.txt"End Sub
回复

使用道具 举报

千问 | 2007-8-4 17:02:49 | 显示全部楼层
我给你个思路文本框1中的行数记录下来,保存到变量iRows中dim strAry(iRows) as integer分组后第i组数据就是从strAry数组中去读取写一个函数,到strAry数组中找到指定行数
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行