?? form1.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1
Caption = "文件分離器"
ClientHeight = 1995
ClientLeft = 60
ClientTop = 450
ClientWidth = 3720
LinkTopic = "Form1"
ScaleHeight = 1995
ScaleWidth = 3720
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog dlgCommonDialog
Left = 1200
Top = 1200
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "生成文件"
Height = 375
Left = 2160
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "打開文件"
Height = 375
Left = 360
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Label Label1
Caption = $"Form1.frx":0000
ForeColor = &H00FF0000&
Height = 1095
Left = 120
TabIndex = 2
Top = 720
Width = 3495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim inputfilename As String
Private Sub Command1_Click()
'aa = Right("243515", 1)
With dlgCommonDialog
.DialogTitle = "Open"
.Flags = 0
.CancelError = False
.FileName = ""
.Filter = "(*.txt)|*.txt"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
inputfilename = .FileName
End With
End Sub
Private Sub Command2_Click()
Dim filehead(10) As String
Dim fileDuan(50, 2) As String
Dim fileduanlu()
Dim filepath As String
Dim outfilename As String
'
'fileDuan(1, 0) = "-311,15"
'fileDuan(1, 1) = "3"
'
'fileDuan(2, 0) = "-312,15"
'fileDuan(2, 1) = "3"
'
'fileDuan(3, 0) = "-313,15"
'fileDuan(3, 1) = "2"
On Error GoTo err
If inputfilename <> "" Then
duanlu_num1 = 0
aa = Len(inputfilename)
For i = 1 To aa
If Mid(inputfilename, i, 1) = "." Then
duanlufile = Mid(inputfilename, 1, i - 1)
outfilename = Right(duanlufile, i - k - 1)
k = i
End If
If Mid(inputfilename, i, 1) = "\" Then
filepath = Mid(inputfilename, 1, i - 1)
inputfile = Mid(inutfilename, i + 1, aa - i)
k = i
End If
Next
Open duanlufile & ".dat" For Input As #4
Do Until EOF(4)
Line Input #4, text1
longtext1 = Len(text1)
For i = 1 To longtext1
If Mid(text1, i, 1) = ";" Then
fileDuan(duanlu_num1, 0) = Mid(text1, 1, i - 1)
fileDuan(duanlu_num1, 1) = Mid(text1, i + 1, longtext1 - i)
duanlu_sub = duanlu_num1
End If
Next
duanlu_num1 = duanlu_num1 + 1
Loop
Close #4
Open inputfilename For Input As #1 '
'讀出文件頭
For i = 1 To 9
Line Input #1, filehead(i)
Next
FileName = 1
Do Until EOF(1)
Line Input #1, linetext
If linetext <> "" Then
For j = 0 To duanlu_sub
If linetext = fileDuan(j, 0) Then
ReDim fileduanlu(fileDuan(j, 1) - 1)
fileduanlu(0) = linetext
duanlu_num = 0
For jj = 1 To fileDuan(j, 1) - 1
Line Input #1, fileduanlu(jj)
duanlu_num = jj
Next
Line Input #1, linetext
End If
Next
Open outfilepath & FileName & "." & outfilename & ".txt" For Output As #2
For i = 1 To 9
Print #2, filehead(i)
Next
For jj = 0 To duanlu_num
Print #2, fileduanlu(jj)
Next
Print #2, linetext
Close #2
FileName = FileName + 1
End If
Loop
Close #1
Else
MsgBox "您還沒有打開要處理的文件,請點打開文件按鈕,選擇您要處理的文件!!!"
End If
Exit Sub
err:
MsgBox err.Description
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -