Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have an MSHFlexGrid and a command

Status
Not open for further replies.

DeeDee

Programmer
Jul 13, 2000
34
0
0
US
I have an MSHFlexGrid and a command button on a form. When the button is clicked, the text in the grid can be saved to a text file. In the file, the text prints out in one column, under one another. There are 3 columns in the grid so I want the text to print out in 3 columns instead of one. Does anybody know if there is a way to do this? Thanks for any help!!
 
If you're writing the file yourself, you could try something like the following:
Code:
for RowID = 0 to grdGrid.Rows - 1
   for ColID = 0 to grdGrid.Cols - 1
      print #FileHand, grdGrid.TextMatrix(RowID, Colid), ' note the comma at the EOL - this will tab to the next column rather than print a CRLF in the output file
   next ColId
   print #FileHand ' Here we move to next line
next RowID
This will print in three separate columns, but they may not necessarily line up, depending on the lengths of the various data items.

To force specific column start positions, I would build a string, concatenating each column data together, insuring that the starting points for each column are the same.
Code:
for RowID = 0 to grdGrid.Rows - 1
   OutLine = vbNullString
   for ColID = 0 to grdGrid.Cols - 1
      ColDataString = String(25, " ")
      LSet ColDataString = grdGrid.TextMatrix(RowID, Colid)
      OutLine = OutLine & ColDataString
   next ColID
   print #FileHand, OutLine
next RowID
This will force each column to occupy 25 postions in the output file.

Note: Due to other activities on the machine at the moment, I cannot actually run this code to text it, but it should be pretty close Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
That worked great. I changed it just a little bit. Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top