|
-
Jan 8th, 2003, 10:54 PM
#1
Thread Starter
Member
Can you save a datagrig to a .txt file?[RESOLVED]
Is it possible to save the contents of a datagrid to a .txt file using code similar to this:
Private Sub SaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
SaveFileDialog1.Filter = "Text files (*.txt)|*.txt"
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName <> "" Then
FIleOpen(1, SaveFileDialog1.FileName, OpenMode.Output)
PrintLine(1, DataGrid1.(What do I put Here?)
FileClose(1)
Endif
Last edited by Nintendo_Wizard; Jan 16th, 2003 at 12:23 PM.
-
Jan 9th, 2003, 01:28 AM
#2
Hyperactive Member
one way, and maybe not the best, is:
Code:
Public Sub WriteGrid()
Dim myFile As IO.File
Dim SW As IO.StreamWriter
Dim r As Integer
Dim c As Integer
SW = myFile.AppendText("c:\file.txt")
For r = 0 To NumberOfRows - 1
For c = 0 To NumberOfColumns - 1
SW.Write(DataGrid.Item(r,c))
Next c
SW.WriteLine()
Next r
SW.Close()
End Sub
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|