?
Solved

File-Writing Not Working Correctly in VB

Posted on 2003-11-13
7
Medium Priority
?
237 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
[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
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

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.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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