473,378 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

A Button To Select The Next Item In A List Box

I Have A Music Player I Made Using A Tutorial In Visual basic 2008 And The Play Button For This Player Plays The Songs Fine, But The Problem Is The Code:

Expand|Select|Wrap|Line Numbers
  1. AxWindowsMediaPlayer1.Ctlcontrols.next()
Does Not Play The Next Song Imported Into The List Box. So Rather Than Playing Around With That I Figured It Would Be Easier To Have A Button That Will Just Select The Next Item In The List Box (Becuase The Windows Media Player Tool Is Playing Songs Imported Into The List Box) . Unfortunately I Have No Idea how To Do That, So I Was Hoping Someone Could Help me Out?

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
  4.  
  5.     Private Sub shadows_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         Timer1.Enabled = True
  8.         Timer1.Interval = 1
  9.  
  10.     End Sub
  11.  
  12.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  13.  
  14.         Dim F12key As Boolean
  15.         Dim F11key As Boolean
  16.  
  17.         F12key = GetAsyncKeyState(Keys.F12)
  18.         F11key = GetAsyncKeyState(Keys.F11)
  19.  
  20.         If F12key = True Then
  21.             AxWindowsMediaPlayer1.URL = Listbox1.SelectedItem
  22.  
  23.         End If
  24.  
  25.         If F11key = True Then
  26.             AxWindowsMediaPlayer1.Ctlcontrols.stop()
  27.  
  28.         End If
  29.  
  30.  
  31.     End Sub
  32.  
  33. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  34.     OpenFileDialog1.ShowDialog()
  35. End Sub
  36.  
  37. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  38.     AxWindowsMediaPlayer1.URL = Listbox1.SelectedItem
  39. End Sub
  40.  
  41. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  42.     AxWindowsMediaPlayer1.Ctlcontrols.stop()
  43. End Sub
  44.  
  45. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  46.     AxWindowsMediaPlayer1.Ctlcontrols.pause()
  47. End Sub
  48.  
  49. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  50.     AxWindowsMediaPlayer1.Ctlcontrols.next()
  51. End Sub
  52.  
  53. Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  54.     AxWindowsMediaPlayer1.Ctlcontrols.previous()
  55. End Sub
  56.  
  57. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  58.  
  59. End Sub
  60.  
  61.     Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
  62.         For Each track As String In OpenFileDialog1.FileNames
  63.             Listbox1.Items.Add(track)
  64.         Next
  65.  
  66.     End Sub
  67.  
  68.  
  69.     Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  70.  
  71.  
  72.  
  73.     End Sub
  74. End Class
Also Just Ignore This Part
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3.     Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
  4.  
  5.     Private Sub shadows_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         Timer1.Enabled = True
  8.         Timer1.Interval = 1
  9.  
  10.     End Sub
  11.  
  12.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  13.  
  14.         Dim F12key As Boolean
  15.         Dim F11key As Boolean
  16.  
  17.         F12key = GetAsyncKeyState(Keys.F12)
  18.         F11key = GetAsyncKeyState(Keys.F11)
  19.  
  20.         If F12key = True Then
  21.             AxWindowsMediaPlayer1.URL = Listbox1.SelectedItem
  22.  
  23.         End If
  24.  
  25.         If F11key = True Then
  26.             AxWindowsMediaPlayer1.Ctlcontrols.stop()
  27.  
  28.         End If
  29.  
  30.  
  31.     End Sub
Thats Just A Universal Hotkey, Which Already Works Fine.
May 7 '10 #1
1 3268
Guido Geurs
767 Expert 512MB
dear,

I have used next code in VB6 (can be used in VB2008 ????)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Com_down_play_Click()
  2. ' select next in the list
  3.    With FileListBox
  4.       If .ListIndex < .ListCount - 1 Then .Selected(.ListIndex + 1) = True
  5.    End With
  6.    With MMControl
  7.          .Command = "Stop"
  8.          .Command = "Close"
  9.          .FileName = FileListBox.Path & "\" & FileListBox.FileName
  10.          .Command = "Open"
  11.          .From = Val(Text_seconden) * 1000
  12.          .Command = "Play"
  13.    End With
  14. End Sub
Hope this will help
May 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Neo Geshel | last post by:
I have an Access DB, from which I am going to pull images. Each image has an associated ID, but the ID's are not necessarily sequential (some images may have been deleted, leaving gaps in the list...
5
by: robecflo | last post by:
Hi Forum, i have a problem, hope somebody can give me ideas. I'm developing with windows forms and vb.net, and oracle as a database. At this moment i have a table called amortizaciones, this table...
10
by: kimiraikkonen | last post by:
Hello, I have a moodest mp3 player which has a playlist as listbox1 which shows full path or each inserted file. The problem is, when a media playing is ended, i want my listbox to select...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.