?
Solved

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

Posted on 2003-03-18
10
Medium Priority
?
183 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

770 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