Open any file and List.

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: May 2005
Posts: 57
Reputation: Prahaai is an unknown quantity at this point 
Solved Threads: 0
Prahaai's Avatar
Prahaai Prahaai is offline Offline
Junior Poster in Training

Open any file and List.

 
0
  #1
Apr 19th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 57
Reputation: Prahaai is an unknown quantity at this point 
Solved Threads: 0
Prahaai's Avatar
Prahaai Prahaai is offline Offline
Junior Poster in Training

Re: Open any file and List.

 
0
  #2
Apr 19th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 188
Reputation: aparnesh is an unknown quantity at this point 
Solved Threads: 10
aparnesh's Avatar
aparnesh aparnesh is offline Offline
Junior Poster

Re: Open any file and List.

 
0
  #3
Apr 20th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Open any file and List.

 
0
  #4
Apr 20th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 57
Reputation: Prahaai is an unknown quantity at this point 
Solved Threads: 0
Prahaai's Avatar
Prahaai Prahaai is offline Offline
Junior Poster in Training

Re: Open any file and List.

 
0
  #5
Apr 24th, 2006
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. :-|
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Open any file and List.

 
0
  #6
Apr 24th, 2006
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, 168 views)
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 57
Reputation: Prahaai is an unknown quantity at this point 
Solved Threads: 0
Prahaai's Avatar
Prahaai Prahaai is offline Offline
Junior Poster in Training

Re: Open any file and List.

 
0
  #7
Apr 24th, 2006
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, 48 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Open any file and List.

 
0
  #8
Apr 24th, 2006
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....
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 57
Reputation: Prahaai is an unknown quantity at this point 
Solved Threads: 0
Prahaai's Avatar
Prahaai Prahaai is offline Offline
Junior Poster in Training

Re: Open any file and List.

 
0
  #9
Apr 24th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Open any file and List.

 
0
  #10
Apr 24th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC