1,502
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Dim i As Long
Dim j As Long
Dim strSj
Dim strj() As String
' 设置“CancelError”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置标志
CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & "(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
' 指定缺省的过滤器
CommonDialog1.FilterIndex = 2
' 显示“打开”对话框
CommonDialog1.ShowOpen
' 显示选定文件的名字
Debug.Print CommonDialog1.FileName
str = CommonDialog1.FileName
Open CommonDialog1.FileName For Input As #1
Do Until EOF(1)
Line Input #1, s
strSj = strSj & s & vbCrLf
i = i + 1
Loop
Close #1
Text1 = strSj
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
Exit Sub
End Sub
用Replace函数来替换Chr(32)+Chr(13)+Chr(10)为空字符串。
Replace函数,返回一个字符串,该字符串中指定的子字符串已被替换成另一子字符串,并且替换发生的次数也是指定