home *** CD-ROM | disk | FTP | other *** search
/ PC User 2008 February / Australian_PC_User_2008-02.iso / magstuff / files / Visual Basic / code.txt next >
Encoding:
Text File  |  2007-11-29  |  1.8 KB  |  46 lines

  1. 'Option 1 ****************
  2.  
  3.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.  
  5.         My.Computer.FileSystem.CurrentDirectory = "C:\windows\media"
  6.         ListBox1.DataSource = My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CurrentDirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.wav")
  7.     End Sub
  8.  
  9.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10.         If ListBox1.SelectedItem <> "" Then
  11.             Me.AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem.ToString
  12.         Else
  13.             MsgBox("Please select a file", MsgBoxStyle.OkOnly, "Select a file")
  14.         End If
  15.     End Sub
  16.  
  17.  
  18.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  19.         End
  20.     End Sub
  21.  
  22.  
  23. 'Option 2**********
  24.  
  25.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  26.  
  27.         My.Computer.FileSystem.CurrentDirectory = "C:\windows\media"
  28.         For Each File As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CurrentDirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.wav")
  29.             ListBox1.Items.Add(My.Computer.FileSystem.GetFileInfo(File).Name)
  30.         Next
  31.     End Sub
  32.  
  33.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  34.         If ListBox1.SelectedItem <> "" Then
  35.             Me.AxWindowsMediaPlayer1.URL = My.Computer.FileSystem.CurrentDirectory + "\" + ListBox1.SelectedItem.ToString
  36.         Else
  37.             MsgBox("Please select a file", MsgBoxStyle.OkOnly, "Select a file")
  38.         End If
  39.     End Sub
  40.  
  41.  
  42.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  43.         End
  44.     End Sub
  45. End Class
  46.