?
Solved

How do I code this DOS command in VB6

Posted on 2009-07-01
7
Medium Priority
?
361 Views
Last Modified: 2013-11-25
This command on the command line in a DOS box works fine.
    copy /b song 1.mp3+song 2.mp3+song 3.mp3 allsongs.mp3
It combines all 3 songs into 1 song and the result is a file that plays all 3 songs one after another.
How do I envoke that command from a VB6 application?
(NOTICE: the space between the word "song" and the number after it)
(Please show me how to do it if there is a space or if there isn't one)
I've tried differend SHELL string combinations but I'm not having any luck.
?

copy /b song 1.mp3+song 2.mp3+song 3.mp3 allsongs.mp3
 copy /b song1.mp3+song2.mp3+song3.mp3 allsongs.mp3

Open in new window

0
Comment
Question by:rbend
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 3

Expert Comment

by:astroviper
ID: 24759520
I don't have vb6 to test this but the actual command string worked for me (without the escape slashes)

Shell("copy /b \"song 1.mp3\"+\"song 2.mp3\"+\"song 3.mp3\" allsongs.mp3") 

Open in new window

0
 

Author Comment

by:rbend
ID: 24759664
I have to ammend my previous description of the issue.
I am taking the contents of text boxes and using that as the data for the string.
So, textbox one will have " C:\songs\song1.mp3" in it.
Text box two will have "C:\songs/song2.mp3" in it etc
WIth that, I need to be able to execute from VB, what would be the equivalent in DOS.
The DOS command would be  "copy /b song1.mp3+song2.mp3 allsongs.mp3

My impression of the VB command is:
 shell("copy b/ " + text1.text + text2.text + "allsongs.mp3")
but that doesn't work for a lot of reasons.
What will work please?
 
0
 
LVL 3

Expert Comment

by:astroviper
ID: 24759772
Ah I see. I'm making the assumption that \ is the escape character so \" will put a double quote inside the string. In VBScript it's ""... Also assuming that + is VB6's concatenation operator, in VBScript it's &.
I don't know if it'll work but you may certainly try it:

shell("copy /b \"" + text1.text + "\"+\"" + text2.text + "\" allsongs.mp3")

Open in new window

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 24760335
astroviper sounds like he is getting you in the right direction.

While '+' will combine strings, it's better to use the '&' symbol (both add string together)... and by this I mean to use the '&' sybmol to concatinate strings (you still need the '+' sign in your DOS command that you are trying to run inside of shell).

'\' isn't a VB escape character.  To get a quotation mark embedded inside a VB string, you use two double quotes.

And lastly, I would suggest that you build the shell command in a string variable first, that way you can test the value to see if it really is what you want before sending it to the shell command.
Dim Command as String
Command = "copy /b """ & text1.text & """+""" & text2.text & """+""" & text3.text & """ ""allsongs.mp3"""
Debug.print "[" & Command & "]" 
Shell( Command )
 
'Command should be something like...
'copy /b "song1.mp3"+"song2.mp3"+"song3.mp3" "allsongs.mp3"

Open in new window

0
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 200 total points
ID: 24760359
BTW, a trick I like to use to keep quoation marks strait (so you don't have to remember when to use double, tripple, or even quad quotation marks) is to define the constant...

Global Const QUOTATION_MARK as String = """"

Then to include a quoation mark in a string, use the constant...

str = QUOTATION_MARK & "Text in Quotes" & QUOTATIONMARK

It makes the code a bit longer (because connatentating the constant is more code than doubling the quotes) but it makes the code SO MUCH MORE READABLE!!!!
0
 
LVL 3

Expert Comment

by:astroviper
ID: 24760465
Thanks HooKooDooKu,
I've never done VB before, only VBScrict and I was extrapolating using what I'd found during a quick visual basic google. That syntax is exactly the same as VBScript and the one I'd used to test that I'd put the quotes in the right place. Didn't expect that.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question