944,131 Members | Top Members by Rank

Ad:
Apr 19th, 2006
0

Open any file and List.

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Prahaai is offline Offline
59 posts
since May 2005
Apr 19th, 2006
0

Re: Open any file and List.

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Prahaai is offline Offline
59 posts
since May 2005
Apr 20th, 2006
0

Re: Open any file and List.

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.
Reputation Points: 20
Solved Threads: 10
Junior Poster
aparnesh is offline Offline
193 posts
since Jul 2005
Apr 20th, 2006
0

Re: Open any file and List.

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Apr 24th, 2006
0

Re: Open any file and List.

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.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub button1_Click()
  2. ShellExecute "track1.mp3"
  3. 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. :-|
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Prahaai is offline Offline
59 posts
since May 2005
Apr 24th, 2006
0

Re: Open any file and List.

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.
Attached Files
File Type: zip ShellExecuteExample.zip (2.7 KB, 474 views)
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Apr 24th, 2006
0

Re: Open any file and List.

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:
Attached Files
File Type: zip M EXE.zip (3.5 KB, 184 views)
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Prahaai is offline Offline
59 posts
since May 2005
Apr 24th, 2006
0

Re: Open any file and List.

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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. selitem = list1.list(list1.listindex)
and that will return the value (in a single-select only listbox) selected in the listbox....
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Apr 24th, 2006
0

Re: Open any file and List.

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Prahaai is offline Offline
59 posts
since May 2005
Apr 24th, 2006
0

Re: Open any file and List.

You should have started a new thread.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. open textfile for input as #1
  2. open htmlfile for output as #2
  3. do until eof(1)
  4. line input #1, chk
  5. print #2, chk & "<BR>"
  6. loop
  7. close #1
  8. close #2
or
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. open textfile for input as #1
  2. open htmlfile for output as #2
  3. do until eof(1)
  4. line input #1, chk
  5. chk = Replace(chk, vbNewLine, "<BR>")
  6. loop
  7. close #1
  8. close #2
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: if then else, case
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Scrollbar in Form (VB6.0)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC