vb中txt文件读入msflexgrid

来源:百度知道 编辑:UC知道 时间:2024/06/28 05:47:58
53698 2005 1 1 2 10227 -70 43 315 10
53698 2005 1 1 3 10222 -75 47 270 3
53698 2005 1 1 4 10217 -64 38 315 12
如上所示的txt数据读入到msflexgrid控件中的,具体怎样实现,请求帮助!

根据你的要求写的,需要添加两个按钮和一个MSFlexGrid,点击command1后再点击command2 

Private Sub Command1_Click() 

Dim myInPut As String, myLine() As String, myData() As String, a As Integer, b As Integer 

Open "c:\1.txt" For Binary As #1 

myInPut = Input(LOF(1), 1) 

Close 

myLine = Split(myInPut, vbCrLf) 

myData = Split(myLine(0), vbTab) 

MSFlexGrid1.Rows = UBound(myLine) + 1 

MSFlexGrid1.Cols = UBound(myData) + 1 

For a = 0 To UBound(myLine) 

myData = Split(myLine(a), vbTab) 

For b = 0 To UBound(myData) 

MSFlexGrid1.TextMatrix(a, b) = myData(b) 

Next 

Next