Solved

File-Writing Not Working Correctly in VB

Posted on 2003-11-13
7
225 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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