Solved

File-Writing Not Working Correctly in VB

Posted on 2003-11-13
7
226 Views
Last Modified: 2010-05-01
When I run this code, the data I want to write will not be written to the file.  After a few failed attempts at making this work, I set some breakpoints, and all of the variables are being set correctly, as is the code in the While loop.  For some reason, though, the data I am trying to write to the file is still never written.

ratings(theindex) = txtrating.Text
names(theindex) = MediaPlayer1.FileName
Open "ratings.txt" For Output As #1
    Dim appenddata As String
    theindex = 0
    While theindex < 10000 And names(theindex) <> ""
        appenddata = names(theindex) & "¦" & rating(theindex)
        Print #1, appenddata
        DoEvents
        theindex = theindex + 1
    Wend
Close #1
0
Comment
Question by:darkshadow88
7 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9742785
what is in ratings and names?

ratings(theindex) = txtrating.Text
names(theindex) = MediaPlayer1.FileName

what is the initial theindex?

can you give example of data in ratings and names and expected output
0
 

Author Comment

by:darkshadow88
ID: 9742876
theindex starts at zero. I am making an MP3 player, and one function is rating songs and playing back at a frequency based on the rating.  ratings is an array that stores the ratings on a 100-point scale, and names is an array that stores the filenames.  An example of my expected output is:

E:\My Music\Less Than Jake\Less Than Jake - All My Best Friends Are Metalheads.mp3¦75

which would be the path to the mp3 file, followed by a delimiter, then the rating.
0
 

Author Comment

by:darkshadow88
ID: 9742891
Never mind... I fixed the problem by using the full path to the text file.
0
 
LVL 3

Expert Comment

by:gajendra
ID: 9745094
Then you ought to search your disk - the previous ratings.txt must also have been made.

In some default folder like My Documents ... or something.

Gajendra
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10191286
PAQed, with points refunded (80)

Computer101
E-E Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 584
Passing a Text Box name to a Sub 6 99
VB6 ListBox Question 4 48
add criteria to query in VB, Access 2003 2 10
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 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