I've written a simple program in VB 6.0 to list all my MP3 files. To show
them on the screen I used an MSFlexGrid named TextGrid (which is not
associated with any table or text file) in the following code run by a
button (the files are all in the format "Artist - Name Of Song" in their
directories, which is why the code looks for a dash):
Private Sub Command1_Click( )
Dim dashplace%, length%
For I% = 0 To File1.ListCount
FLIName = File1.List(I%) 'the text of the whole line
dashplace% = InStr(FLIName, "-") 'the position of the dash
length% = Len(FLIName) 'length of the whole line
If dashplace% = 0 Then
If FLIName <> "" Then
Text1 = FLIName & " is an invalid entry."
End If
Else:
Aname = Mid(FLIName, 1, dashplace% - 1) 'Artist's name
If LetterSort = "XX" Then
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
TextGrid.AddIte m Aname & vbTab & NameOfSong & vbTab &
Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
TextGrid.ColAli gnment(2) = 0
Else
Select Case Text2.Text
Case Is = "View By Artist"
If Mid(Aname, 1, 1) = LetterSort Then
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
TextGrid.AddIte m Aname & vbTab & NameOfSong & vbTab
& Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
End If
Case Is = "View By Title"
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
If LetterSort <> "XX" Then 'show only a particular
letter
If Mid(NameOfSong, 1, 1) = LetterSort Then
TextGrid.AddIte m Aname & vbTab & NameOfSong &
vbTab & Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
End If
End If
End Select
End If
End If
Next I%
End Sub
This code works fine, and fills the MSFlexGrid with the data I want, but I
have absolutely no idea how to print it. I've looked through all the
manuals I have and nothing seems to work. If I use "Printer.pr int TextGrid"
it only prints the first column, first row of data (there are two columns,
one for artist the other for song name). Is there a way to print this
directly to a printer or to export it to a Word for Windows document or a
text document or anything?
Phil Benson
them on the screen I used an MSFlexGrid named TextGrid (which is not
associated with any table or text file) in the following code run by a
button (the files are all in the format "Artist - Name Of Song" in their
directories, which is why the code looks for a dash):
Private Sub Command1_Click( )
Dim dashplace%, length%
For I% = 0 To File1.ListCount
FLIName = File1.List(I%) 'the text of the whole line
dashplace% = InStr(FLIName, "-") 'the position of the dash
length% = Len(FLIName) 'length of the whole line
If dashplace% = 0 Then
If FLIName <> "" Then
Text1 = FLIName & " is an invalid entry."
End If
Else:
Aname = Mid(FLIName, 1, dashplace% - 1) 'Artist's name
If LetterSort = "XX" Then
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
TextGrid.AddIte m Aname & vbTab & NameOfSong & vbTab &
Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
TextGrid.ColAli gnment(2) = 0
Else
Select Case Text2.Text
Case Is = "View By Artist"
If Mid(Aname, 1, 1) = LetterSort Then
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
TextGrid.AddIte m Aname & vbTab & NameOfSong & vbTab
& Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
End If
Case Is = "View By Title"
NameOfSong = Mid(FLIName, dashplace% + 1, length% -
(dashplace + 1) - 3)
If Mid(NameOfSong, 1, 1) = " " Then
NameOfSong = Mid(NameOfSong, 2, 255)
End If
If LetterSort <> "XX" Then 'show only a particular
letter
If Mid(NameOfSong, 1, 1) = LetterSort Then
TextGrid.AddIte m Aname & vbTab & NameOfSong &
vbTab & Dir1.Path
TextGrid.ColAli gnment(0) = 0
TextGrid.ColAli gnment(1) = 0
End If
End If
End Select
End If
End If
Next I%
End Sub
This code works fine, and fills the MSFlexGrid with the data I want, but I
have absolutely no idea how to print it. I've looked through all the
manuals I have and nothing seems to work. If I use "Printer.pr int TextGrid"
it only prints the first column, first row of data (there are two columns,
one for artist the other for song name). Is there a way to print this
directly to a printer or to export it to a Word for Windows document or a
text document or anything?
Phil Benson
Comment