Solved

File-Writing Not Working Correctly in VB

Posted on 2003-11-13
7
221 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
Comment Utility
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
Comment Utility
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
Comment Utility
Never mind... I fixed the problem by using the full path to the text file.
0
 
LVL 3

Expert Comment

by:gajendra
Comment Utility
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
Comment Utility
PAQed, with points refunded (80)

Computer101
E-E Admin
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now