请教版主和各位高手,如何将文本1的内容转成文本2,内容如下:
有个文本内容如下:* 2005 12 31 0 0 0.00000000
PG01 -15246.320949 18519.427777 -11153.726375 26.821894
PG02 19741.327715 -12513.110413 12184.817005 -24.395785
PG03 -11327.137706 22733.013103 7067.034835 61.722682
* 2005 12 31 0 15 0.00000000
PG01 -14911.467205 17109.204322 -13560.588565 26.823994
PG02 21064.424892 -12541.591712 9735.216414 -24.395405
PG03 -11454.270199 21692.492469 9639.507890 61.724323
* 2005 12 31 0 30 0.00000000
PG01 -14583.297001 15430.116335 -15730.824330 26.825362
PG02 22104.609765 -12558.716077 7114.555593 -24.394939
PG03 -11583.378716 20379.636429 12042.213682 61.725495
用下面代码
Private Sub Command1_Click()
Open Text1.Text For Input As #1
Dim Heads() As String
Dim value1 As Single
Dim tmpStr As String
Dim m As Integer
Do While Not EOF(1)
Line Input #1, tmpStr
tmpStr = Trim(tmpStr)
Do While InStr(tmpStr, " ") > 0
tmpStr = Replace(tmpStr, " ", " ")
Loop
Heads = Split(tmpStr)
For m = 1 To 6
List1.AddItem Heads(m)
Next
Line Input #1, tmpStr
tmpStr = Trim(tmpStr)
m = InStrRev(tmpStr, " ")
value1 = Val(Mid(tmpStr, m))
List1.AddItem value1
Line Input #1, tmpStr
Line Input #1, tmpStr
List1.AddItem ""
Loop
End Sub
生成的文本是以一列的方式存放的,请问如何将文本1的内容:
PG01
-15246.320949
18519.427777
-11153.726375
26.821894
PG02
19741.327715
-12513.110413
12184.817005
-24.395785
PF03
-11327.137706
22733.013103
7067.034835
61.722682
.
.
.
.
.
.
PH998
-14911.467205
17109.204322
-13560.588565
26.823994
PH999
21064.424892
-12541.591712
9735.216414
-24.395405
PI1000
-11454.270199
21692.492469
9639.507890
61.724323
.
.
.
生成格式如下的文本2呢:
1,PG01, -15246.320949,18519.427777, -11153.726375,26.821894
2,PG02,19741.327715, -12513.110413, 12184.817005,-24.395785
3,PF03, -11327.137706,22733.013103,7067.034835,61.722682
.
.
.
.
.
.
998,PH998, -14911.467205,17109.204322,-13560.588565,26.823994
999,PH999,21064.424892,-12541.591712,9735.216414,-24.395405
1000,PI1000,-11454.270199,21692.492469,9639.507890,61.724323
.
.
.