Solved

File-Writing Not Working Correctly in VB

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

749 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