哪位高手会用vb编个读文件的程序啊?

来源:百度知道 编辑:UC知道 时间:2024/05/25 06:26:56
在vb里我编了个文件菜单,文件下一级菜单又编了个读文件菜单,现在我要通过编个代码来读出我需要打开的文件,能帮帮我吗?拜托了了。PG01是卫星号,后面三个分别是x,y,z坐标 一共有32个卫星,它们每15分钟x,y,z坐标就会变一次 ,
2007 6 25 0 0 0.00000000
PG01 13727.978892 -13345.559437 -18168.814076
PG02 -22717.522396 13139.211638 2661.720747
PG03 10898.866883 -18672.752893 14992.828896
PG04 -25007.705342 5166.175066 -8007.835277
.... .. .... .....
.... .. .... ....
PG31 ... .. ..

2007 6 25 0 15 0.00000000
PG01 13615.093545 -11146.199994 -19663.813463
PG02 -23013.109458 12933.150287 -177.492075
PG03 11256.152723 -16811.839622 16826.143603
PG04 -24181.999348 4480.663580 -10540.344078
... .. ... ....

已修改...
=====================================================
=====================================================
Dim FileContents As String
Dim PG() As String
Dim PGData() As String
Dim PGNum() As String
Dim X() As String
Dim Y() As String
Dim Z() As String

FileNum = FreeFile

Open "C:\1.txt" For Binary As #FileNum
FileContents = Space(LOF(FileNum))
Get #FileNum, , FileContents
PG = Split(FileContents, vbCrLf)
Close #FileNum

ReDim PGNum(UBound(PG)) As String
ReDim X(UBound(PG)) As String
ReDim Y(UBound(PG)) As String
ReDim Z(UBound(PG)) As String

For i = UBound(PG) - 31 To UBound(PG)
If Left(PG(i), 2) = "PG" Then
PGData = Split(PG(i), " ")
PGNum(i) = PGData(0)
X(i)