Create/Rename Batch Files and Combine Textboxes

CornMaster
09-12-2000, 12:00 PM
Can anyone tell me how to write batch files in VB and then rename them to what ever the user wants. I can write .ini files but renaming that to a .bat won't work because of the headers and stuff.
And I'd also like to know how to combine the text into 2 textboxes. For example Text1.text = "Cold" and Text2.text = "Weather" how could I make text3.text = "Cold Weather"?????
If I've confused anyone sorry.

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

whelanp
09-12-2000, 12:19 PM
1) .BAt files

Open "C:x.bat" for output as #1

print #1, "cd MyDirSubDir"
print #1, "MyProj.exe"

close #1



2) text3 = text1 & " " & text2

As Text is a textboxes default property you don't have to use it.

CornMaster
09-12-2000, 12:22 PM
I see. Looks pretty simple. I'll give it a spin. Thanks

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

whelanp
09-12-2000, 12:23 PM
Forget the renaming bit.

To name the file before creation.

Dim strFileName as string

Set strFileName from a text box, an input box or from your INI file.

then its

Open "C:"" & strFilename & ".bat" for output as #1

Dazz
09-12-2000, 12:24 PM
Batch files are just simple sequencial ascii text files with the file extension .Bat. They can be easily created in DOS Edit or Windows Notepad. So all you really need to do is dump the commands that you require in a seuencial file (ask if you need help with this) and name the file what ever the user specifies.

The second question would go as follows :-
Text3.text = Text1.Text & Text2.Text

To make sure that you have a space in the middle you can trim all spaces, and manually input the middle space.
Text3.text = Trim(Text1.Text) & " " & Trim(Text2.Text).

Hope it helps!
Live2Give

CornMaster
09-12-2000, 01:08 PM
Ok everything is working so far but how do I create a second line in the batch file?

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

Dazz
09-12-2000, 01:10 PM
How did you create the first line ?

whelanp2
09-12-2000, 01:33 PM
You can add as many print # lines in your create batch procedure as you like.

CornMaster
09-12-2000, 01:33 PM
I created the 1st line with this code from above:
but this is the code I'm using. I just can't get it to write the 3 lines
Open "C:quake2.bat" For Output As #1

Print #1, Text3
Close #1

Open "C:quake2.bat" For Output As #2
Print #2, Text2
Close #2
Open "C:quake2.bat" For Output As #3
Print #3, addons
Close #3

Shell "c:quake2.bat"

I'm assuming #1 means 1st line but I guess I'm wrong because when I put #2 and #3 is makes no difference.

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

usetheforce2
09-12-2000, 01:46 PM
hey cornmaster, just open the file once and then print what you want to write to the file:
open app.path + "quake2.bat" for output as #1
print #1, text2
print #1, text3
print #1, addons
close #1

the only reason you use a specific file number is to distinguish between each file that is open
eg, if you had three files open and you want to file two
all you need to do is speciy the file number such as
print #2 ' will print whatever to file number two.
some times you will see the function "freefile" what this does is it will get you a file number that is not used: that way you need not to keep track of the files which are open.

good luck!
Regan DeDiana

CornMaster
09-12-2000, 02:11 PM
That worked great. Thanks. I'm creating a loader for Quake 2 because I hate typing in all the commands at the command line. I just need to find all the commands.
Right know it can load a map and select the skill level and launch the game. If anyone would want this when I'm done just say so and I'll give you the link.

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

usetheforce2
09-12-2000, 02:18 PM
quake2 kicks "*****" i'd like to see how you go about, and see it when your finished Cornmaster. C-ya
Regan DeDiana

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum