程序代码:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim s(100) As String '因不知道你的具体有多少,所有我用了100,自己替换掉
Dim i, j As Integer
Dim strFileName As String
Private Sub Command1_Click()
On Error GoTo ms:
With Me.CommonDialog1
.Filter = "txt文件|*.txt"
.ShowOpen
End With
strFileName = Me.CommonDialog1.FileName
If Len(strFileName) > 0 And Dir(strFileName) <> "" Then
i = 1
Open strFileName For Input As #1
Do While Not EOF(1)
Line Input #1, s(i)
i = i + 1
Loop
Close #1
End If
ms:
End Sub
Private Sub Command2_Click()
Dim st As String
Open strFileName For Output As #1
For j = 1 To i
st = st + s(j) + ";"
Next j
Print #1, st
Close #1
End Sub
因为不知道你每40个加什么间隔,所以我就直接没给你加,你自己加上就行了。另外为了方便选择文件,用了一个CommonDialog控件,需要手动加入控件