- 注册时间
- 2007-10-6
- 最后登录
- 1970-1-1
- 阅读权限
- 50
- 金币
- 元
- 记录
- 相册
- 性别
- 保密
|
这个简单的转换程序。绝对适合初学者。'================================
'放一个DriveListBox(Name = D),一个DirListBox(Name = Di),一个FileListBox(Name = F,MultiSelect = 2),一个CommandButton(Name = Command1),一个TextBox(Name = Text1,MultiLine = Ture,Scroll = 2),一个Label(Name = Label1,“"”)
'===============================
'代码部分:
Private Sub Command1_Click()
For i = 0 To F.ListCount - 1
If F.Selected(i) Then
Text1.Text = FileText(Di.Path & "\" & F.List(i))
'开始替换字符串
Text1.Text = Right(Text1.Text, Len(Text1) - InStr(1, Text1.Text, "<song>") - 5)
Text1.Text = Replace(Text1.Text, "<title>", "[ti:")
Text1.Text = Replace(Text1.Text, "</title>", "]")
Text1.Text = Replace(Text1.Text, "</singer>", "]")
Text1.Text = Replace(Text1.Text, "</album>", "]")
Text1.Text = Replace(Text1.Text, "<singer>", "[ar:")
Text1.Text = Replace(Text1.Text, "<album>", "[al:")
Text1.Text = Replace(Text1.Text, "</song>", "")
Text1.Text = Replace(Text1.Text, "<duration>", "[tim:")
Text1.Text = Replace(Text1.Text, "</duration>", "]")
Text1.Text = Replace(Text1.Text, "<editor>", "")
Text1.Text = Replace(Text1.Text, "</editor>", "")
Text1.Text = Replace(Text1.Text, "<name>", "[by:")
Text1.Text = Replace(Text1.Text, "</name>", "]")
Text1.Text = Replace(Text1.Text, "<lines>", "")
Text1.Text = Replace(Text1.Text, "<line begin=" & Label1.Caption, "[")
Text1.Text = Replace(Text1.Text, "<line begin", "")
Text1.Text = Replace(Text1.Text, Label1.Caption & ">", "]")
Text1.Text = Replace(Text1.Text, "</line>", "")
Text1.Text = Replace(Text1.Text, "</lines>", "")
Text1.Text = Replace(Text1.Text, "</Lyric>", "")
保存为Lrc文件
fl = Replace(Di.Path & "\" & F.List(i), ".krc", ".lrc")
Open fl For Output As #1
Print #1, Text1.Text
Close #1
Kill Di.Path & "\" & F.List(i)
End If
Next
End Sub
Private Sub D_Change()
Di.Path = D.Drive
End Sub
Private Sub Di_Change()
F.Path = Di.Path
End Sub
Function FileText(ByVal filename As String) As String '一种快速打开TXT文件的方法
Dim handle As Integer
' 判断文件存在性
If Len(Dir$(filename)) = 0 Then
Err.Raise 53 '文件没有找到
End If
' 以binary模式打开文件
handle = FreeFile
Open filename$ For Binary As #handle
' 读取内容,关闭文件
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function |
|