Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

URGENT!!! - Create a text file in VB SCRIPT

Posted on 2003-03-18
10
Medium Priority
?
187 Views
Last Modified: 2010-05-01
I already know how to create a simple text file in normal Vb6.

What I need to know is what is the code for creating a file in VB SCRIPT.

VB6 Code....

Open "Textfile.txt" For Output As #99
print #99,"Simple Text File"
Close #99

This code will create and edit the fiel Textfile.txt Can anybody tell me what I need to do to make this work for VB SCRIPT

I need to do this today so if any body can help Guarnteed Grade A Answer!!!
0
Comment
Question by:RussellMartin
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 152 total points
ID: 8158679
Hi RussellMartin,

VBScript doesn't support the native file functions of VB. You need to use the FileSystemObject:

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set a = fso.CreateTextFile("c:\testfile.txt", True)
    a.WriteLine("This is a test.")
    a.Close


Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
 
LVL 2

Author Comment

by:RussellMartin
ID: 8158776
Now I get an error activex object cant be created

any ideas
0
 
LVL 2

Author Comment

by:RussellMartin
ID: 8158809
Now I get an error activex object cant be created

any ideas
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:itzme
ID: 8158944
You need to include the reference Microsoft Scripting runtime:
choose References from the Project menu), select Microsoft Scripting Runtime (SCRRUN.DLL)
you'll have to declare the fso variable
Dim fso As New fileSystemObject
0
 

Expert Comment

by:itzme
ID: 8158974
You need to add the reference "Microsoft Scripting Runtime"
from the References dialog in the Projects menu.
Also declare fso in the code given by tim after including the reference:
Dim fso As New fileSystemObject
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8159161
Start > Run > REGSVR32 C:\WINNT\SYSTEM32\SCRRUN.DLL
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 148 total points
ID: 8159570
There is no problem with reference, You are creating object at runtime so Refrence is not required.
But, it could be that sccrun.dll is not installed in target machine or not properly registered.
If you try to run that code from internet, maybe that could not work.
0
 

Expert Comment

by:CleanupPing
ID: 8532087
Hi RussellMartin,
This old question (QID 20554626) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8957201
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->Split between TimCottee and aelatik

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9028352
ups!, what happens here?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

578 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