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

📄 form1.frm

📁 这是用VB写嘚播放器程序
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5265
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8100
   LinkTopic       =   "Form1"
   ScaleHeight     =   5265
   ScaleWidth      =   8100
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog cmdDialog 
      Left            =   840
      Top             =   240
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.ListBox soundList 
      Height          =   2940
      Left            =   600
      TabIndex        =   5
      Top             =   840
      Width           =   5055
   End
   Begin VB.CommandButton Command5 
      Caption         =   "stop"
      Height          =   495
      Left            =   3600
      TabIndex        =   4
      Top             =   4080
      Width           =   1695
   End
   Begin VB.CommandButton Command4 
      Caption         =   "play"
      Height          =   495
      Left            =   960
      TabIndex        =   3
      Top             =   4080
      Width           =   1575
   End
   Begin VB.CommandButton Command3 
      Caption         =   "exit"
      Height          =   615
      Left            =   6120
      TabIndex        =   2
      Top             =   3240
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      Caption         =   "delete"
      Height          =   615
      Left            =   6120
      TabIndex        =   1
      Top             =   2160
      Width           =   1695
   End
   Begin VB.CommandButton Command1 
      Caption         =   "insert"
      Height          =   615
      Left            =   6120
      TabIndex        =   0
      Top             =   960
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim filename As String
Dim filepath As String

Private Sub Command1_Click()
Dim fname, fpath, s As String
cmdDialog.Filter = "(音频文件)*.wma|*.wma"
cmdDialog.ShowOpen
fname = cmdDialog.FileTitle
fpath = cmdDialog.filename
On Error GoTo dosome
s = "insert into soundtable values('" + fname + "','" + fpath + "')"
cmd.ActiveConnection = cn
cmd.CommandText = s
cmd.Execute
soundList.AddItem fname
Exit Sub
dosome:
 MsgBox "当前的歌曲已在数据库中存在!"
End Sub

Private Sub Command2_Click()
Dim s As String

If soundList.ListIndex <> -1 Then
s = soundList.List(soundList.ListIndex)
cmd.CommandText = "delete from soundtable where soundname='" + s + "'"
cmd.Execute
soundList.RemoveItem soundList.ListIndex
End If
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Command4_Click()
filename = soundList.List(soundList.ListIndex)
cmd.CommandText = "select * from soundtable where soundname='" + filename + "'"
Set rs = cmd.Execute
filepath = rs.Fields("soundpath").Value
mciExecute "open " + filepath + "alias mywav"
mciExecute "play mywav"
End Sub

Private Sub Command5_Click()
mciExecute "close mywav"
End Sub

Private Sub Form_Load()
On Error GoTo dosome
cn.ConnectionString = "driver={sql server};server=DBC35B6620F64B4;uid=;pwd=;database=sound"
cn.Open
cmd.ActiveConnection = cn
cmd.CommandText = "select * from soundtable"
Set rs = cmd.Execute
While Not rs.EOF
soundList.AddItem rs.Fields("soundname").Value
rs.MoveNext
Wend
rs.Close
Exit Sub
dosome:
  MsgBox "数据库连接错误!"
End Sub

⌨️ 快捷键说明

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