VB分割文件问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 17:55:15
Private Sub Command1_Click()
Dim key As Boolean
Dim mingzi As String
'On Error Resume Next
If Dir(Text1.Text) = "" Then MsgBox "请输入文本路径!": Text1.SetFocus: Exit Sub
Open Text1.Text For Input As #1
temp = StrConv(InputB(LOF(1), #1), vbUnicode)
Close #1
key = False
mingzi = ""
n = 0
legth = Len(temp)
For i = 1 To legth
zi = Mid(temp, i, 1)

If key = False Then
If zi <> "/" And zi <> "\" And zi <> " " Then mingzi = mingzi & zi
End If
If zi = "/" Then key = True
If key = True Then
If zi <> "/" And zi <> "\" Then txt = txt & zi
End If

If zi = "\" Then key = False
If key = False And txt <> "" Then
Print mingzi
n = n + 1
dizhi = "C:\Documents and Settings\Administrator\

太长,看得累。

其实 有那么复杂吗 ?

open "e:\1.txt" for input as #1
dim temp as string
使 text1.text= 文件内容 ;
然后用 mid(text1.text,1,len(text1.text)/3)=temp
再用 open 语句将 temp 写入到 记事本中就 好了 !