hi folks
can you help me please....
I have a radio button on my form which plays a tune when clicked
my.computer.audio.play ("c:\windows\media\song1.wav", _
radio button.text= song1........
this button can play any song...if the song is renamed song1.....
but what I want to do is let the user change the radio button .text to the name of the
choosen song...and save it.....
so that when the form loads the radio button displays the name of the song
instead of song1....
ps....I am stupid so I may need some code
thank you so much
cheyenne

radio button help
thisishaydes
This will allow the user to select a wave file to play and set just the name of the wave file to the radiobutton text:
Private
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim TheWaveFIle As String = String.Empty Dim ofd As New OpenFileDialog ofd.Filter = "Wave Files|*.wav" If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then If File.Exists(ofd.FileName) Then TheWaveFIle = New FileInfo(ofd.FileName).Name End If End If If Not String.IsNullOrEmpty(TheWaveFIle) Then My.Computer.Audio.Play(ofd.FileName) Me.RadioButton1.Text = TheWaveFIle End If End Subcr4zykilla
The following should allow you to modify the radio button songs, by selecting one - clicking on the button and selecting a file.
The are then saved in the application settings file - so when you come stop the program and restart it they are loaded back. Its pretty basic but should get you going.
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SetupButtons()
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Try
Select Case CType(sender, RadioButton).Name
Case "RadioButton1"
If My.Settings.SongName1.Length > 0 Then My.Computer.Audio.Play(My.Settings.SongName1)
Case "RadioButton2"
If My.Settings.SongName2.Length > 0 Then My.Computer.Audio.Play(My.Settings.SongName2)
End Select
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TheWaveFIle As String = String.Empty
Dim ofd As New OpenFileDialog
ofd.Filter = "Wave Files|*.wav"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
If My.Computer.FileSystem.FileExists(ofd.FileName) Then
TheWaveFIle = New System.IO.FileInfo(ofd.FileName).Name
Select Case Me.RadioButton1.Checked
Case True
My.Settings.SongName1 = ofd.FileName
Case False
My.Settings.SongName2 = ofd.FileName
End Select
My.Settings.Save()
SetupButtons()
End If
End If
End Sub
Sub SetupButtons()
Me.RadioButton1.Text = My.Settings.SongName1
Me.RadioButton2.Text = My.Settings.SongName2
End Sub
End Class
NeederOfVBHelp
ok guys
I have played around with your code and I now have a button which allows the user to open and choose a song...
and display the title......thanks guys.............I am pretty happy with that
the save part I cannot get to work....but that dont really matter.......it suits me for now........thanks a lot
cheyenne
StephenH
thank you so much guys
I will play around with that
thank you
cheyenne