Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2005, 09:37 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing Value from Variable into Text File

Hi there, Im relatively new to VB. Im trying to store a value from variable TotalCost to the first position of a text file. Here is the cunnk of code im using:

Dim Filename As String
Dim TotalCost As Variable

Filename = \\Home\shareddocs\Mateusz's Work\HND\HND Year 2 2004-05\Existing Units\Unit 15\Unit 15 Ass 2\Ass 2\C&C\textfile.txt

Open Filename For Input As #1
Write #1, TotalCost


Im getting a “ Runtime Error “54” Bad File Mode”

Can somebody be kind enough to please advise me on where im going wrong and provide a little help, would really be appreciated! Cheers

Dabigpolska


DaBigPolska
 
Old January 6th, 2005, 11:07 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Try with "For Output" or "For Append"

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 7th, 2005, 05:34 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The perspective of Input and Output with respect to files is that of the program.

Input allows you to read data into the program.
Output allows the program to ptu stuff out into the file.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing data to a variable Mikect VB Databases Basics 1 April 16th, 2007 01:53 PM
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
Storing an include in a variable trufla Beginning PHP 1 May 21st, 2006 10:52 PM
how to variable keep a value from text file? cslimcom C++ Programming 0 December 26th, 2004 10:13 PM
Print value of a variable to text file SubodhKumar SQL Language 2 December 10th, 2003 03:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.