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.AddItem Aname & vbTab & NameOfSong & vbTab &
Dir1.Path
TextGrid.ColAlignment(0) = 0
TextGrid.ColAlignment(1) = 0
TextGrid.ColAlignment(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.AddItem Aname & vbTab & NameOfSong & vbTab
& Dir1.Path
TextGrid.ColAlignment(0) = 0
TextGrid.ColAlignment(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.AddItem Aname & vbTab & NameOfSong &
vbTab & Dir1.Path
TextGrid.ColAlignment(0) = 0
TextGrid.ColAlignment(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.print 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 5 13343
You must set up a loop looking at each row and each column, then print
that "cell" data.
Use the .rows (to get number of rows), .row (to set the row you are
on, and .col (to set the column you are on) methods. The .text method
tells you the text in the "cell". Then Print #x, .text; for each
column, ending the last column without a semi-colon (to get a new
line).
Example (I have separated columns on the printout using the TAB
command):
Dim X%
For X% = 0 To grdOutput.Rows - 1
grdOutput.ROW = X%
grdOutput.col = 1
Print #1, grdOutput.text;
Print #1, Tab;
grdOutput.col = grdOutput.col + 1
Print #1, grdOutput.text;
Print #1, Tab;
grdOutput.col = grdOutput.col + 1
Print #1, grdOutput.text;
Print #1, Tab;
grdOutput.col = grdOutput.col + 1
Print #1, grdOutput.text
Next X%
--
---
Allen
Free astrology software at: http://www.astrowin.org
"MouseHart" <Mo*******@trap.net> wrote in message
news:9j********************@news4.srv.hcvlny.cv.ne t... 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.AddItem Aname & vbTab & NameOfSong & vbTab
& Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(1) = 0 TextGrid.ColAlignment(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.AddItem Aname & vbTab & NameOfSong
& vbTab & Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(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.AddItem Aname & vbTab &
NameOfSong & vbTab & Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(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.print
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
Thank you very much. I will implement this and see what happens. I wonder
why the book I use for reference ("Visual Basic from the Ground Up") and
Microsoft's on-line help don't make this obvious. Maybe they figure no one
will ever need to print data.
"Woof-Woof" <ot*********@cox.net> wrote in message
news:sTjAc.4935$8r5.4687@fed1read03... You must set up a loop looking at each row and each column, then print that "cell" data. Use the .rows (to get number of rows), .row (to set the row you are on, and .col (to set the column you are on) methods. The .text method tells you the text in the "cell". Then Print #x, .text; for each column, ending the last column without a semi-colon (to get a new line).
Example (I have separated columns on the printout using the TAB command):
Dim X%
For X% = 0 To grdOutput.Rows - 1 grdOutput.ROW = X% grdOutput.col = 1
Print #1, grdOutput.text; Print #1, Tab;
grdOutput.col = grdOutput.col + 1 Print #1, grdOutput.text; Print #1, Tab;
grdOutput.col = grdOutput.col + 1 Print #1, grdOutput.text; Print #1, Tab;
grdOutput.col = grdOutput.col + 1 Print #1, grdOutput.text Next X%
--
--- Allen
Free astrology software at: http://www.astrowin.org
"MouseHart" <Mo*******@trap.net> wrote in message news:9j********************@news4.srv.hcvlny.cv.ne t... 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.AddItem Aname & vbTab & NameOfSong & vbTab & Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(1) = 0 TextGrid.ColAlignment(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.AddItem Aname & vbTab & NameOfSong & vbTab & Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(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.AddItem Aname & vbTab & NameOfSong & vbTab & Dir1.Path TextGrid.ColAlignment(0) = 0 TextGrid.ColAlignment(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.print 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
I had to modify your code as follows in order to make it work:
Dim X%
For X% = 0 To TextGrid.Rows - 1
TextGrid.Row = X%
TextGrid.Col = 0
Printer.Print , TextGrid.Text;
TextGrid.Col = TextGrid.Col + 1
Printer.Print , TextGrid.Text
Next X%
For some reason, if I use the line
Print #1, TextGrid.text;
it gives me a "Bad File Name or Number" error on that line, and yet it shows
the correct value for TextGrid.text. The bright side is that it actually
prints, which is more than it did before.
Using Printer.Print seems to correct the error, and the Tab call makes it
somewhat too wide for my purposes, so I removed that. All that being said,
it prints fine except that every few lines the alignment is screwy. For
example, it will read:
The Beatles Help
The Doors The End
Paul Newman Plastic Jesus
Note that the song "Plastic Jesus" is not aligned with the other two. I
have no idea why, and I'm not sure it's important to me at this point.
One last question: is it possible to just send the data to a text file and
pick up the text file with a word processing program from outside VB, or can
the data be sent directly to something like Word using the Microsoft Word
Document insertable object from the components list (either way would be
fine, although sending it directly to Word would be better)? Thanks for
bearing with me on this.
Phil Benson
>> One last question: is it possible to just send the data to a text
file and
pick up the text file with a word processing program from outside VB,
or can
the data be sent directly to something like Word using the Microsoft
Word
Document insertable object from the components list (either way would
be
fine, although sending it directly to Word would be better)? Thanks
for
bearing with me on this.
Yes. In general, here is how you write to a file:
Close #1
Open "nameoffile.txt" for Output As #1
'you can set up your loop in here - I only show one line of text being
printed to file
Print #1, TextGrid.Text
Close #1
I have never tried working with the Word object, but I don't see why
what you ask is not possible.
--
---
Allen
"MouseHart" <Mo*******@trap.net> wrote in message
news:D2*********************@news4.srv.hcvlny.cv.n et... I had to modify your code as follows in order to make it work:
Dim X%
For X% = 0 To TextGrid.Rows - 1 TextGrid.Row = X% TextGrid.Col = 0 Printer.Print , TextGrid.Text; TextGrid.Col = TextGrid.Col + 1 Printer.Print , TextGrid.Text Next X%
For some reason, if I use the line Print #1, TextGrid.text; it gives me a "Bad File Name or Number" error on that line, and yet
it shows the correct value for TextGrid.text. The bright side is that it
actually prints, which is more than it did before.
Using Printer.Print seems to correct the error, and the Tab call
makes it somewhat too wide for my purposes, so I removed that. All that
being said, it prints fine except that every few lines the alignment is screwy.
For example, it will read:
The Beatles Help The Doors The End Paul Newman Plastic Jesus
Note that the song "Plastic Jesus" is not aligned with the other
two. I have no idea why, and I'm not sure it's important to me at this
point. One last question: is it possible to just send the data to a text
file and pick up the text file with a word processing program from outside
VB, or can the data be sent directly to something like Word using the Microsoft
Word Document insertable object from the components list (either way
would be fine, although sending it directly to Word would be better)?
Thanks for bearing with me on this.
Phil Benson
Thanks for your help. I'll give this a try also. Yes. In general, here is how you write to a file:
Close #1 Open "nameoffile.txt" for Output As #1
'you can set up your loop in here - I only show one line of text being printed to file Print #1, TextGrid.Text
Close #1
I have never tried working with the Word object, but I don't see why what you ask is not possible.
--
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Schapopa |
last post by:
I am using MS Access and VB 6.0
I am trying to create MSFlexGrid with the same data that I have in the
Excel spreadshit, and that is:
Jan03 Feb03 March03
Data1 2 3 4...
|
by: Ed |
last post by:
Hi,
I am using an MSflexgrid in my c# code.
I have a strange problem. My MSflexgrid has only 1 column.
Now the data in that column can be long. WIth just 1 column the MSflexgrid
does not show...
|
by: David Sawyer |
last post by:
I am attempting to capture data from the serial port,
place that data into a MSFlexGrid and then use that data
to parse out Lat/Lon to plot to a map.
The problem I am having is when I attempt to...
|
by: Tulasi |
last post by:
Hi all,
This is very uregent requirement.Requirement is, i am using MSFlexgrid in
vb.net .At the run time this grid contains some data items.Any body knows
how to print these rows using...
|
by: Steven |
last post by:
I develop the application which contains MSFlexGrid to display data. When I
try to fill the grid with the text data, I want to adjust the column width
so that the width is adjusted to the maximum...
|
by: rekhasc |
last post by:
hi..........
i just want to print the msflexgrid ................. instead of printing a form...... can any one help me plz............ i am using vb6.0 and the back end is ms access
|
by: smartchap |
last post by:
In VB6 in a form there are 10 labels and associated 10 textboxes and 2 MSFlexGrids. There are 5 columns in the first MSFGrid and 7 in the second MSFGrid. There are 3 rows in the first grid and 4 in...
|
by: JuAn2226 |
last post by:
hi,I got few question here. Hope some one can me. plz help me i running out of time
1. how to make my msflexgrid to display data for every 5 min(especially the
number car and average speed.
...
|
by: mahesh123 |
last post by:
Hi Folks,
How can i export the data from the MSFlexGrid to the MS Open Office Excel in VB 6.0? I Can Know how to export data from the MSFlexgrid to the MS Office Excel.
Please Help me regarding...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |