1:) Please, how can i make Visual Basic 6 open a HTML file (with Iexplore, let's say), or one MP3 (with Media Player instead of Winamp, let's say), when i click a button? It is possible?
I mean, for the HTML, i need the default program to open the file, but for mp3, i really want media player.

2:) I have a list with 20 songs. When i click one of them (let's say song mumber 4), the buttons PLAY anf LYRICS appear. I don't know how to make only mp3 number 4 to play when i click item number 4 in the list. Big problem for me... The html lyrics are very easy to run, i use labels, it's exactly like the mp3.

Please, please, plese help.

Maybe 2: is not easy to understand.
I have a form and a ListBox on it. In this listbox, i have 20 items in a list (i pasted the names if each track). Each item from the List corespounds with a ItemData, 1 is for track number 1, 2 is for track number 2 and so on. 20 is for track number 20.
Now, when i execute the program, i see the form and the listbox. When i click, let's say track number 4, 2 new buttons appear: PLAY and LYRICS. Play will play the mp3 and lyrics will open the html file with the lyrics. Simple as that.
I dont know how to open one CERTAIN MP3 from the list, with Winamp, from the click of one button. This is all i want to do.

Thank you in advance.

If u are using the filenames of the mp3 files, u can try the ShellExecute API function. It will open the file named in the arguement list wih the default application for the file.

And you can still use shellexecute to execute a program without it's "default" loading operation. Meaning, you can load media player with the filename you want it to play as a parameter, instead of calling the .mp3 (or whatever) directly.

Errr...
One more problem: what lybrary do i have to add for this ShellExecute function to work? Or, what should i define? I don't know how API works...

Let's suppose i want "track1.mp3" to be launched when i press button1.

Private Sub button1_Click()
ShellExecute "track1.mp3"
End Sub

doesn't work (function not defined), considering that the "track1.mp3" is in the same directory as the executable.
I'm sorry... my visual basic skills are very low. :( :-|

Depends on if you want to launch the MP3 with the default application or not...... here is an example project that you can use that allows you to select if you want to use the default application, or if you want to specify an application to use when launching the file. It's fully commented, so let me know how it turns out for you.

Ok. Opening files works LIKE A MIRACLE! That part of the question is 100% solved.


Now, the select file from a listbox part. When i created the "ListBox" i went to ItemData and completed the field with the list of 4 files, and then i completed the "List" with 0, 1, 2, and 3.

Here is the attached project.
I still don't know how to execute only the SELECTED file from one long list of files in listbox. In this example, i used 4 files, but what if i have 100 files? And what if they are not called that simple, "track(x).mp3"?... big problem for me... :rolleyes:

I don't understand completely what you are trying to do.... but I can tell you that in order to get the selected item in the listbox, you can say:

selitem = list1.list(list1.listindex)

and that will return the value (in a single-select only listbox) selected in the listbox....

Perfect. The code you gave me worked almost as i wanted. :mrgreen:
So everything would be solved in here.
Now, i have another question, but i think i should do another thread, cose it it has nothing to do with this one...

Better not make a new thread:

I have a very very very long text (*.TXT) file. The lines are small, but many. Now i want to make this a HTML file. The <html><body> tags are easy to do, the HUGE problem is adding a <br> at the end of each line. Now, i know it is very simple to detect the end of each line in Visual Basic and add a "<br>" string at the end, WITHOUT altering the text written in there...
Please? I know i have to open the txt file for reading and writing... but i am stuck after this point.

You should have started a new thread.

open textfile for input as #1
open htmlfile for output as #2
do until eof(1)
     line input #1, chk
     print #2, chk & "<BR>"
loop
close #1
close #2

or

open textfile for input as #1
open htmlfile for output as #2
do until eof(1)
     line input #1, chk
     chk = Replace(chk, vbNewLine, "<BR>")
loop
close #1
close #2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.