473,320 Members | 1,722 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,320 software developers and data experts.

VB6 Event Handler

I am trying to create an event handler that detects when there is a song change in iTunes. The iTunes COM has an "OnPlayerPlayEvent" just for such a purpose. I have the VB.NET code (shown below) but can't seem to get a version to work in VB6. Any suggestions?

Imports iTunes.Lib
Public Class frmMain
‘set up the values for iTunes interaction
Dim iTunes as New iTunesApp

Private Sub frmMain_Load(ByVal sender As Object, byVal e As System.EventArgs) Handles Me.Load
‘ Trigger Event on Song Change
AddHandler iTunes.OnPlayerPlayEvent, AddressOf EventHandler
End Sub

Private Sub EventHandler(ByVal iTrack As Object) Handles iTunes.OnPlayerPlayEvent
MsgBox(“Song Changed”, MsgBoxStyle.Information)
End Sub
End Class
Feb 25 '12 #1
2 4917
I figured it out. It was quite simple. The first step is to add a reference to your VB6 project. The reference to add is iTunes 1.13 Type Library.

Here is the code:

Under General_Declarations

Dim WithEvents iTunes As iTunesApp

Under Form_Load

Set iTunes = CreateObject("iTunes.Application")
' this will start iTunes if it is not already running

Create a New Sub

Private Sub iTunes_OnPlayerPlayEvent(ByVal iTrack As Variant)
Call MsgBox("Song Changed: " & iTunes.CurrentTrack.Name
End Sub

Launch the application. If iTunes is not running it will start it. If it is already running then it will join that instance. Start a song in iTunes. The vb6 application will popup an information message box with the name of the currently playing song. Click OK in the message box. Everytime a new song starts the message box will pop up.
Feb 26 '12 #2
Killer42
8,435 Expert 8TB
Thanks for posting your solution, it should help anyone else who comes looking with a similar problem.
Mar 13 '12 #3

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

Similar topics

7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
15
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
3
by: Beth | last post by:
in the following: this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click); if I saw an equation, such as y +=x; then y = y+x. But what is the meaning in the event handler. I...
5
by: james | last post by:
Hello, I am having a little trouble creating an event handler for a context menu toolstripmenuitem. I've seen various tutorials and so on, but I keep getting a bit stuck! So far I have a second...
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
2
by: =?Utf-8?B?UlJK?= | last post by:
Hello, I would like to add the Paint handler to the form. How to do it? Thanks in advance.
4
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Hi all, Recently I found an interesting question on C# forums about clearing event handlers of an event. I tried to give it a solution, but failed. I am interested to know how you guys take...
2
by: wolverine | last post by:
Hi All, In Mozilla Firefox, to onblur and onfocus event of each and every html element, the browser itself will attach a native event handler. I mean if you type,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.