Reading Text File
Reading Text File
Reading Text File
Reading Text File
Reading Text File
Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File
Reading Text File Reading Text File
Reading Text File
Go Back  Xtreme Visual Basic Talk > > > Reading Text File


Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2008, 08:19 PM
zdt zdt is offline
Newcomer
 
Join Date: May 2008
Posts: 9
Default Reading Text File


I converted a midi to a text file for use in a Guitar Hero clone for vb6 that looks like this:

MFile 1 2 480
MTrk
0 Tempo 600000
15000 On ch=1 n=84 v=127
15092 Off ch=1 n=84 v=64
15250 On ch=1 n=87 v=127
15342 Off ch=1 n=87 v=64
15450 On ch=1 n=86 v=127

This goes on much longer, but this is just a snippet. The long numbers on the left(15000, 15092) are the times the notes occur at. "On" means a note starts and "off" means it ends. "Ch" is the channel and "n" is the note represented in midi numbers. There are only five different notes in this file, so it should be easy. The question is: How can I make VB read the .txt file and interpret it to have a note start scrolling down the screen at the specified time and on the correct fret as detailed in the text file. The note 84 is the first fret, 85 the second, etc.
Thanks
Reply With Quote
  #2  
Old 05-07-2008, 02:18 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

First of all you need to know how to load a file. If you dont then there is a File I/O Tutorial. I dont think it would matter much which way you load the file (text or binary). My prefered method would be to open it as a binary file so you can get the entire contents of the file then split it into an array of lines. You may want to load it as a text file instead because it will give you 1 line at a time.

The rest really depends on your program. What are the "notes" that scroll down the screen? Pictureboxes? Shapes? Before you try to parse out the values in the file i would setup a test so that you can get the notes to scroll down the screen when you click a command button. Once youve done that it should be easy enough to swap the command button with an array of numbers (the time each not is played).

As for parsing the file you could split each line into an array (split using a space). Now you already have the time and the state in seperate elements in the array. The other 3 elements will still have the equals and the bit before it eg. Element 2 in the array would contain "ch=1". You can use Right(), Len() and Instr() to get the value. Infact you dont even need Instr() since you know how many characters to cut off the begining.
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #3  
Old 05-07-2008, 07:32 AM
zdt zdt is offline
Newcomer
 
Join Date: May 2008
Posts: 9
Default

Thank you so much. I don't know why I couldn't think of that before. Thanks again
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reading Text File
Reading Text File
Reading Text File Reading Text File
Reading Text File
Reading Text File
Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File Reading Text File
Reading Text File
Reading Text File
 
Reading Text File
Reading Text File
 
-->