954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Click to play audio

Hello everyone, i need a bit of help.
On a click of a button i want to pay an audio file.... here is my code


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = "1" Then
TextBox2.BackColor = Color.LawnGreen
C:\Users\Nick\Desktop\good_work.play

now for some reason it says syntax error? help me!!!

nv136
Light Poster
30 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

First, your If statement needs a closing End If statement.

If TextBox2.Text = "1" Then
            TextBox2.BackColor = Color.LawnGreen
            'C:\Users\Nick\Desktop\good_work.play
        End If

Second, you cannot just paste a file's full path, especially one without a file extension and expect nothing but errors.
You have to declare it.

Dim myCoolFile As String = "C:\Users\Nick\Desktop\good_work.wav"

And finally, check out this thread. How do I make a program in VB make a sound when it starts?

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

Hello everyone, i need a bit of help. On a click of a button i want to pay an audio file.... here is my code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox2.Text = "1" Then TextBox2.BackColor = Color.LawnGreen C:\Users\Nick\Desktop\good_work.play

now for some reason it says syntax error? help me!!!


If you are try to play the audio player with windows media player then you need the code to start the player which is a system process.
Here is the code to start the windows media player
System.Diagnostics.Process.Start("wmplayer.exe")

mbrown686886
Newbie Poster
6 posts since Aug 2010
Reputation Points: 10
Solved Threads: 1
 

Codeorder, thanks..... post something in reply and then i will mark the thread as solved

nv136
Light Poster
30 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

:yawn:

codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: