- ©«¤l
- 835
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 915
- ÂI¦W
- 14
- §@·~¨t²Î
- Win 10,7
- ³nÅ骩¥»
- 2019,2013,2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2024-11-6
|
¥»©«³Ì«á¥Ñ luhpro ©ó 2015-2-25 22:24 ½s¿è
¦U¦ì¿Ë·Rªº¤j¤j¤È¦w
¦³Ó¤p°ÝÃD·Qn¸ò¦U¦ì½Ð¯q¡A
n¦p¦ó±N¤@Ó¦³¦n´X¦æ¸ê®ÆªºtxtÀÉ¡A¶×¥X¦¨¨C¤@¦æ ...
flowrew µoªí©ó 2015-2-25 13:58
¶È´N§A´£¨Ñªº¹ÏÀɲq´ú¤å¦rÀɪº¤º®e,¸Õ¸Õ¬Ý...- Sub nn()
- Dim iMode%, iBgn%, iCol%
- Dim lRow&
- Dim sStr$, sTemp$
- Dim vD
- Dim vFs, vF
-
- Cells.Clear
-
- Set vD = CreateObject("Scripting.Dictionary")
- lRow = 3
- iCol = 3
- iMode = 0
- Set vFs = CreateObject("Scripting.FileSystemObject")
- Set vF = vFs.OpenTextFile(ThisWorkbook.Path & "\123.txt", 1, -2)
- Do While Not vF.AtEndOfStream
- sStr = Trim(vF.ReadLine)
- If sStr <> "" Then
-
- Select Case iMode
- Case Is > 2 ' ¸ê®Æ°Ï
- iBgn = InStr(1, sStr, " ")
- Cells(vD("1"), iCol) = Left(sStr, iBgn - 1)
-
- iBgn = InStr(iBgn, sStr, " ")
- GoSub SkipSpace
- Cells(vD("2"), iCol) = sTemp
-
- iBgn = InStr(iBgn, sStr, " ")
- GoSub SkipSpace
- Cells(vD("3"), iCol) = sTemp
-
- iBgn = InStr(iBgn, sStr, " ")
- GoSub SkipSpace
- Cells(vD("3") + 1, iCol) = sTemp
-
- iBgn = InStr(iBgn, sStr, " ")
- GoSub SkipSpace
- Cells(vD("4"), iCol) = sTemp
- iCol = iCol + 1
-
- Case 0 ' SN
- If InStr(1, sStr, "SN") > 0 Then
- Cells(lRow, 2) = "SN"
- Cells(lRow, 3) = Trim(Mid(sStr, InStr(1, sStr, ":") + 1, 10))
- iMode = iMode + 1
- lRow = lRow + 1
- End If
-
- Case 1 ' Model
- If InStr(1, sStr, "Model") > 0 Then
- Cells(lRow, 2) = "Model"
- Cells(lRow, 3) = Trim(Mid(sStr, InStr(1, sStr, ":") + 1, 10))
- iMode = iMode + 1
- lRow = lRow + 2
- End If
- Case 2 ' A B C D
- iBgn = InStr(1, sStr, " ")
- Cells(lRow, 2) = Left(sStr, iBgn - 1)
- vD("1") = lRow
-
- GoSub SkipSpace
- lRow = lRow + 1
- Cells(lRow, 2) = sTemp
- vD("2") = lRow
- iBgn = InStr(iBgn, sStr, " ")
-
- GoSub SkipSpace
- lRow = lRow + 2
- Cells(lRow, 2) = sTemp
- vD("3") = lRow
- iBgn = InStr(iBgn, sStr, " ")
-
- GoSub SkipSpace
- lRow = lRow + 2
- Cells(lRow, 2) = sTemp
- vD("4") = lRow
- iMode = iMode + 1
- End Select
- End If
- Loop
- vF.Close
-
- Exit Sub
- SkipSpace:
- Do While Mid(sStr, iBgn, 1) = " "
- iBgn = iBgn + 1
- Loop
- sTemp = Trim(Mid(sStr, iBgn, IIf(InStr(iBgn, sStr, " ") = 0, _
- Len(sStr) + 1, InStr(iBgn, sStr, " ")) - iBgn))
- Return
- End Sub
½Æ»s¥N½X
test.zip (10.16 KB)
|
|