Drop audio file on button

I added a DropObject to a button.
Here is the code that DOES NOT WORK.
any ideas.

if obj.FolderItemAvailable then
dim f as FolderItem = obj.FolderItem
'Now you have the file reference in f

’ Get the path:
dim path as String = f.NativePath

’ Show the path:
Dim msgbox2 As New MessageDialog
MsgBox path

Did you call AcceptFileDrop to specify which types of files to allow? And does the code actually run. If you put a breakpoint on the first line of code, does it ever get there?

I have no idea what you are talking about, I am very sorry, I am new to this. I can do Auto Hot Key on PC, I’m on Mac at home and am trying to learn XOJO. I know NOTHING about this language. Thanks a million for any help with my goal.

You should start here then: https://www.xojo.com/resources/learn.php

1 Like

Best way learning Xojo is indeed to go through the examples. Try to understand them through debugging. You don’t need to understand each and every bit (and you probably won’t at the beginning), but this will give you the foundation an understanding of the main concepts (events, handlers, etc.). Xojo is relatively easy and the learning curve isn’t very high, but yes at the very beginning you have to go face the hen-egg issue until you are getting more confident.

Your code looks fine until these 2 lines.
“MsgBox” is now (since API 2) called “MessageBox”.
Also, MessageDialog is a class made for advanced dialogs (you can customise buttons, the icon, etc), and MsgBox is a another call for a simple dialog.
You don’t have to create a MessageDialog object in order to show a MessageBox: just put MessageBox “My message” and Xojo handles creating the dialog under the hood. Only if you want to actually use a MessageDialog (not MessageBox), should you use the “Dim msgbox2 As New MessageDialog” line.

Now, you’re mainly wasting a MessageDialog object; that should do nothing bad except creating an unused object in memory. So why does it not work?
When you say “it does not work”, we don’t know what you tried and what you’re getting (a compile-time error? A crash?).
Your code would be called if you added the corresponding AcceptFileDrop call earlier. Did you do that? Does your event gets called at all? (put a breakpoint at the “if” line to check for that).