|
本帖最后由 peterpu 于 2024-7-8 08:08 编辑
Private Sub bkgx()
Dim s$, tt$
Dim ii%, j%, k%
Dim arr As Object
Dim brr As Object
Sheets("Sheet1").Cells.Select
Selection.ClearContents
Open ThisWorkbook.Path & "\block_gn.dat" For Binary As #1
s = VBA.StrConv(VBA.InputB(LOF(1), 1), 64)
Close #1
'下面红色代码由热心老师帮助写出,但现在遇到纯英文字母板块(ChatGPT)后出错,本人VBA略懂一二,但红色代码部分不懂,谢谢帮助!
'预计应该是跟红色代码部分有关,因为本地窗口已经看不到(ChatGPT)的Item项了!
Set arr = getData(s, "(\d{0,1}[A-Z]{0,4}[一-龥]{1,4}[A-Z]{0,4}\d{0,3}[一-龥]{0,4})")
For ii = 0 To arr.Count - 1
If ii = arr.Count - 1 Then
tt = VBA.Mid(s, arr(ii).firstindex + arr(ii).Length + 1, Len(s) - arr(ii).firstindex - arr(ii).Length)
Else
tt = VBA.Mid(s, arr(ii).firstindex + arr(ii).Length + 1, arr(ii + 1).firstindex - arr(ii).firstindex - arr(ii).Length)
End If
Set brr = getData(tt, "(\d{6})")
Sheet1.Cells(1, Sheet1.Cells(1, Columns.Count).End(xlToLeft).Column + 1) = arr(ii)
For j = 0 To brr.Count - 1
A = A + 1
Sheet1.Cells(A + 1, Sheet1.Cells(1, Columns.Count).End(xlToLeft).Column) = brr(j)
Next
A = 0
Next
End Sub
|
|