关于vb的问题 每行文本定义成数组。然后在 MSHFlexGrid显示,文本已经有分割标志了

来源:百度知道 编辑:UC知道 时间:2024/09/24 06:59:51
关于vb的问题 我希望能够将读取的每行文本定义成数组。然后在 MSHFlexGrid显示,文本已经有分割标志了 各位大虾!我很急呀!希望快帮我回答 谢谢各位
本人程序如下
Private Sub mnuFileOpen_Click(Index As Integer)
Dim Str As String
Dim strArray() As String
Dim i As Long
Dim strLine As String
CommonDialog1.Filter = "文本文档(*.txt)│*.txt│RTF文档(*.rtf)│*.rtf│所有文件(*.*)│*.*"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then
MsgBox "错误信息!请选择文件!!!"
ElseIf FileName <> "" Then
Open FileName For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Input #1, strLine
ReDim Preserve strArray(i)
strLines = trArray(i)
i = i + 1

With MSHFlexGrid1
MSHFlexGrid1.TextMatrix(1, 1) = Split(strLine(0), ";")
MSHFlexGrid1.TextMatrix(1, 2) = Split(strLine(1), ";

Private Sub Command1_Click()
Dim strArray, i As Integer
i = 0
Open "c:\a.txt" For Input As #1
strLine = StrConv(InputB(LOF(1), #1), vbUnicode)
Close

strArray = Split(strLine, ";")
With MSF
.TextMatrix(1, 1) = strArray(0)
.TextMatrix(1, 2) = strArray(1)
.TextMatrix(1, 3) = strArray(2)
.TextMatrix(1, 4) = strArray(3)
.TextMatrix(1, 5) = strArray(4)
End With

End Sub