⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 一个简易的MP3播放器。虽然界面不是很好
💻 BAS
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public fn As String
Public mfile() As String
Public mfilejianhua() As String
Public mfileroad() As String
Public fuxuan As Boolean
Public weishu As Integer
Public listliebiao As Integer




Public Function fenliqudededuogewenjianming(fn As String)
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim xx As String
Dim leftfn() As String
Dim rightfn() As String
Dim y As Integer
Dim str As String
n = Len(fn) '---取得返回的文件名内包含字符的数目
For i = 1 To n
xx = Mid(fn, i, 1) '---返回字符串中指定数量的字符
                                       'Mid(字符串, 起点 ,终点)
If Asc(xx) = 0 Then
fuxuan = True
Exit For
Else
fuxuan = False
End If
Next i
If fuxuan = True Then
GoTo Start1
Else
GoTo start2
End If

Start1:
       
       n = Len(fn) '---取得返回的文件名内包含字符的数目
       
       ReDim Preserve leftfn(y) '---重分配数组元数的个数,但不改变里面的数据
       
       For i = 1 To n
           xx = Mid(fn, i, 1) '---返回字符串中指定数量的字符
                                       'Mid(字符串, 起点 ,终点)
           If Asc(xx) = 0 Then
              
              y = y + 1
              
                          '---字符串中从左边算起指定数量的字符
                          'Left(字符串, 起点)
              leftfn(y - 1) = Left$(fn, i - 1)
              
                           '---字符串右边取出的指定数量的字符
                           'Right(字符串, 起点)[起点从右数起]
              fn = Right$(fn, n - i)
              
              GoTo Start1
           
           End If
       Next i
       leftfn(y) = fn '存储了复选的多个文件名,其中第一个是路径,没有\
       '用redim定义的是多维数组,维是从0---Y,复选的文件数等于Y
ReDim mfile(1 To y) As String
For i = 1 To y
mfile(i) = leftfn(i)
Next i
ReDim mfileroad(1 To y) As String
For i = 1 To y
mfileroad(i) = leftfn(0) + "\" + leftfn(i)
Next i
ReDim mfilejianhua(1 To y) As String
For j = 1 To y
n = Len(leftfn(j))
For i = n To 1 Step -1
  xx = Mid(leftfn(j), i, 1)
  If xx = "." Then
  mfilejianhua(j) = Left$(mfile(j), i - 1)
  Exit For
  End If
Next i
Next j
weishu = y
GoTo last
start2:
ReDim mfileroad(1) As String
ReDim mfile(1) As String
ReDim mfilejianhua(1) As String
mfileroad(1) = fn
n = Len(fn)
For i = n To 1 Step -1
  xx = Mid(fn, i, 1)
  If xx = "\" Then
  mfile(1) = Right$(fn, n - i)
  Exit For
  End If
Next i
n = Len(mfile(1))
For i = n To 1 Step -1
  xx = Mid(mfile(1), i, 1)
  If xx = "." Then
  mfilejianhua(1) = Left$(mfile(1), i - 1)
  Exit For
  End If
Next i
weishu = 1
last:
End Function
Public Function jingyibuchuliwenjianming()
If fn = "" Then GoTo last
fenliqudededuogewenjianming (fn)
listliebiao = Form1.List1.ListCount
Dim i As Integer

If listliebiao = 0 Then
  If fuxuan = True Then

    For i = 1 To weishu

      Form1.List1.AddItem mfilejianhua(i), i - 1
      Form1.List2.AddItem mfileroad(i), i - 1
      'listliebiao = listliebiao + 1
    Next i
  Else
  '~~~=mfile(1)
  Form1.List1.AddItem mfilejianhua(1), i
  Form1.List2.AddItem mfileroad(1), i
  'listliebiao = listliebiao + 1
End If
Else
  If fuxuan = True Then

    For i = 1 To weishu

     Form1.List1.AddItem mfilejianhua(i), listliebiao - 1 + i
     Form1.List2.AddItem mfileroad(i), listliebiao - 1 + i
     'listliebiao = listliebiao + 1
    Next i
  Else
     '~~~=mfile(1)
     Form1.List1.AddItem mfilejianhua(1), listliebiao
     Form1.List2.AddItem mfileroad(1), listliebiao
     'listliebiao = listliebiao + 1
  End If
End If
last:

End Function
'//以。秒,分钟,小时的显示时间
Public Sub ToToTime() '----计算时间的过程
   Dim MsecTime As Integer
   Dim SecTime As String
   Dim Sec As String
   Dim ShowTime As String
       Form1.Text2 = ShowTime

       
       MsecTime = (Form1.mp.TotalTime - 1000) \ 1000
       SecTime = str$(MsecTime \ 60)
          
          If Len(SecTime) < 3 Then
             SecTime = "0" + Right(SecTime, 1)
           Else
             SecTime = Right(SecTime, 2)
          End If
       
       Sec = str$(MsecTime Mod 60)
          
          If Len(Sec) < 3 Then
             Sec = "0" + Right(Sec, 1)
           Else
             Sec = Right(Sec, 2)
          End If
       
       'ShowTime = SecTime + "分" + Sec + "秒"
       ShowTime = "00" + ":" + SecTime + ":" + Sec + ":" '//////////////
       Form1.Text2 = ShowTime
End Sub
Public Function mp3pinlv()
    Form1.Text5 = str$(Form1.mp.SampleFrequency \ 1000) + "kHz"

    Form1.Text6 = str$(Form1.mp.BitRate \ 1000) + "kbps"
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -