dim iRow, iCol as integer
dim strLine, strData as stringwith MSFlexGrid
for irow=0 to .rows-1
strLine = ""
.row = iRow
for icol=0 to .cols-1
.col = iCol
strLine = strLine & .text & vbTab
next icol
strline = left(strline,len(strline)-1) & vbNewline
strData = strData & strline
next irow
open "C:\record.txt" for output as #1
print #1,strData
close #1

解决方案 »

  1.   

    to of123() 
    按照你的代码带是生成了txt文件可是文件里面的字段名和自段内容对不奇啊:(
    能不能改进呢?
      

  2.   

    MSFlexGrid里的内容能导出到excale吗?
      

  3.   

    MSFlexGrid里的内容能导出到excel吗?
      

  4.   

    保存至EXCEL 8.0类型的数据库中。
      

  5.   

    '***************************
    怎样将记录集快速导出到Excel:
    '***************************
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    ' Open the recordset.
    Set db = DBEngine.Workspaces(0). _
    OpenDatabase("D:\db1.mdb")
    Set rs = db.OpenRecordset("SELECT _
    * FROM MyTable")
    ' Open the destination Excel workbook.
    Set xlApp = New Excel.Application
    Set xlBook = xlApp.Workbooks. _
    Open("D:\Book1.xls")
    ' This is all it takes to copy the contents
    ' of the recordset into the first worksheet
    ' of Book1.xls.
    xlBook.Worksheets(1).Range("A1"). _
    '*******************
    CopyFromRecordset rs
    '*******************
    ' Clean up everything.
    xlBook.Save
    xlBook.Close False
    xlApp.Quit
    rs.Close
    db.Close
    Set xlBook = Nothing
    Set xlApp = Nothing
    Set rs = Nothing
    Set db = Nothing
      

  6.   

    他告诉我用户定义类型未定义
    Dim xlApp As Excel.Application
      

  7.   

    他告诉我用户定义类型未定义
    Dim xlApp As Excel.Application
    我是有什么没有定义哪?]
      

  8.   

    VB 如何将dbgrid印出来Option Explicit
    Private Sub Command1_Click()
    Dim I As Long, J As Long, K As Long
    Dim PrintString As String
    For I = 0 To Data1.Recordset.RecordCount - 1
    If K = DBGrid1.VisibleRows Then
    DBGrid1.Scroll 0, DBGrid1.VisibleRows
    K = 0
    End If
    For J = 0 To DBGrid1.Columns.Count - 1
    PrintString = PrintString &
    DBGrid1.Columns(J).CellText(DBGrid1.RowBook(K)) & "/"
    Next
    Printer.Print PrintString
    PrintString = ""
    K = K + 1
    DoEvents
    Next
    End SubPrivate Sub Form_Activate()
    Data1.Recordset.MoveLast
    Data1.Recordset.MoveFirst
    End Sub