vb 报错中未找到方法或数据成员

来源:百度知道 编辑:UC知道 时间:2024/05/28 19:46:20
音乐播放器 代码如下
Dim ab As String

Private Sub Command1_Click()
Dim song As String
With Command1
.FontName = ""
.Filter = "video file (*.dat)ㄏ*.datㄏwave file (*.wav)ㄏavi file (*.avi)ㄏ(*.avi)ㄏmovie file (*.mov)ㄏ(*.mov)ㄏmedia file (*.mmm)ㄏ(*.mmm)ㄏmid file (*.mid;*.rmi)ㄏ(*.mid;*.rmi)ㄏmpeg file (*.mpeg)ㄏ(*.mpeg)ㄏall file (*.*)ㄏ*.*"
.ShowOpen
song = .FileName
End With
If song = "" Then Exit Sub
a = ""
For i = Len(song) To 1 Step -1
b = Mid(song, i, 1)
If b = "" Then
List1.AddItem a
a = ""
ElseIf b = "\" Then
List1.AddItem a
ab = Left(song, i)
Exit Sub
Else
a = b & a
End If
Next i

End Sub

Private Sub List1_Click()
Form1.Caption = "播放器" + ab & List1.Text
windowsmediaplay1.URL = ab & List1.Text

End Sub

窗体上应该画一个CommonDialoge控件,你画了吗?

按 ctrl+t 调出“部件”对话框,添加 Microsoft Common Dialog Control 6.0 (SP6) 和 Windows Media Player

而后把它们加到窗体上

以下代码本机测试通过:

Dim ab As String

Private Sub Command1_Click()
Dim song As String
With CommonDialog1
.FontName = ""
.Filter = "video file (*.dat)ㄏ*.datㄏwave file (*.wav)ㄏavi file (*.avi)ㄏ(*.avi)ㄏmovie file (*.mov)ㄏ(*.mov)ㄏmedia file (*.mmm)ㄏ(*.mmm)ㄏmid file (*.mid;*.rmi)ㄏ(*.mid;*.rmi)ㄏmpeg file (*.mpeg)ㄏ(*.mpeg)ㄏall file (*.*)ㄏ*.*"
.ShowOpen
song = .FileName
End With
If song = "" Then Exit Sub
a = ""
For i = Len(song) To 1 Step -1
b = Mid(song, i, 1)
If b = "" Then
List1.AddItem a
a = ""
ElseIf b = "\" Then
List1.AddItem a
ab = Le