【发布时间】:2013-07-07 21:52:10
【问题描述】:
我正在使用 Visual Basic 2010,我正在为我正在构建的程序编写 c 代码,我的问题是我设置了 Media.SoundPlayer,我希望它在表单加载时激活所以我的代码看起来像这样(编辑:此代码不起作用,在调试中加载时声音不会播放,我没有收到错误)
Private Sub BGMusic(ByVal x As Integer)
Dim msp As New Media.SoundPlayer
Dim Music As String = Install + "\Music\innmusic.wav"
msp.SoundLocation = Music
If x = 1 Then
msp.Play()
Else
msp.Stop()
End If
End Sub
Private Sub Innmenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BGMusic(1)
End Sub
我还想指出 Install + "\Music\innmusic.wav" 是一个有效的路径,因为我可以设置一个按钮来运行 BGMusic(1) 并播放音乐。就我的目的而言,form.shown 会起作用,但我想知道我未来的程序出了什么问题,以便我可以使用 form.load
【问题讨论】:
-
+不是 VB 中的字符串连接运算符。&是。 -
@Dan-o + 和 VB.net 中的 & 都适用于字符串连接。
-
我会尝试调试一个镜头,相同的代码适用于不同的表单页面,但在某些页面上似乎无法执行
-
注意:如果你有 Option Strict On,你应该只使用
+来连接字符串。
标签: vb.net winforms visual-studio-2010