Option ExplicitPrivate Type DataInfo
PartName As String
PartNumber As String
End TypeDim NDataInfo() As DataInfo
Private Sub Combo1_Change(Index As Integer)
If Combo1(0).Text <= Combo1(1).Text Then
Call LoadData(Combo1(0).Text, Combo1(1).Text)
Else
Call LoadData(Combo1(1).Text, Combo1(0).Text)
End If
End SubPrivate Sub Form_Load()
Dim i As Integer
Dim sCol()
Dim ii As Long
Dim FG As Long, nn As Long, m As Long
sCol = Array("学年", "班级" ,'要求从2列开始显示0 到999,也就是2列0行是0,3列0行是1,4列0行是2,以此类推到999列) NDataInfo = OpenFile(App.Path & "\cc.txt") For i = LBound(NDataInfo) To UBound(NDataInfo)
Combo1(0).AddItem NDataInfo(i).PartName
Combo1(1).AddItem NDataInfo(i).PartName
Next
Combo1(0).ListIndex = Combo1(0).ListCount - 30
Combo1(1).ListIndex = Combo1(0).ListCount - 1 MSFlexGrid1.Cols = UBound(sCol) + 1 For i = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.TextMatrix(0, i) = sCol(i)
MSFlexGrid1.ColWidth(i) = 800
MSFlexGrid1.ColAlignment(i) = flexAlignCenterCenter
Next
Call LoadData(Combo1(0).Text, Combo1(1).Text)
End SubPrivate Sub Command1_Click()
If Combo1(0).Text <= Combo1(1).Text Then
Call LoadData(Combo1(0).Text, Combo1(1).Text)
Else
Call LoadData(Combo1(1).Text, Combo1(0).Text)
End If
End Sub
Private Sub LoadData(ByVal sStart As String, ByVal sEnd As String)
Dim i As Integer, it As Integer, iw As Integer, j As Integer, k As Integer, b() As Byte, ii As Integer, q(5) As Integer, a As Integer, bt As Integer, c As Integer
Dim ss As String, tmp As String, output(8) As String, Temp As String, rt As String, itt As Integer, iy As Integer, ip As Integer Dim S(5) As String, t As String, sa As String, sai As String, bl As String, al As String, cl As String, h(5) As String
Dim F As Integer, im As Integer, io As Integer, ia(9) As Integer, n As Integer
Dim x As Integer
Dim y As Integer
Dim Sl As String
Dim Dl As String, ss1 As String, ss2 As String, ss3 As String, p As String
MSFlexGrid1.Rows = 1
For i = 1 To UBound(NDataInfo)
If NDataInfo(i).PartName >= sStart And NDataInfo(i).PartName <= sEnd Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
k = MSFlexGrid1.Rows - 1
MSFlexGrid1.TextMatrix(k, 0) = NDataInfo(i).PartName
MSFlexGrid1.TextMatrix(k, 1) = NDataInfo(i).PartNumber
End If
Next
End Sub
Private Function OpenFile(ByVal FileName As String) As DataInfo()
Dim Data() As DataInfo
Dim count As Long
Dim sData() As String Open FileName For Input As #1
sData = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close
ReDim Data(1 To UBound(sData) + 1) For count = 0 To UBound(sData)
Data(count + 1).PartName = Trim(Split(Trim(sData(count)), ",")(0))
Data(count + 1).PartNumber = Trim(Split(Trim(sData(count)), ",")(1))
Next OpenFile = Data
End Function要实现sCol = Array("学年", "班级" ,'要求从2列开始显示0 到999,也就是2列0行是0,3列0行是1,4列0行是2,以此类推到999列)
该怎么写,
i= 0 to 999,
MSFlexGrid1.TextMatrix(0, 2+i) = i
next
但是怎么整和,就是0列的
就剩18分了,都给了
由于太长了,不想写出来?是不是?
哪就写个代码生成器,无非就是字符串的一些操作!
不过这样也不错啊:MSFlexGrid1.TextMatrix(0, 0) ="学年"
MSFlexGrid1.TextMatrix(0, 1) = "班级"
i= 0 to 999,
MSFlexGrid1.TextMatrix(0, 2+i) = i
next
Dim b() As String
b() = Split(sCol, ",") '使用Split函数将字符串分开for i= 0 to 999,
MSFlexGrid1.TextMatrix(0, i+1) = b(i)
next