0

我有一个需要在 vb.net 上工作的 vb6 代码

 Dim strFileName As String
    Dim strText As String
    Dim strFilter As String
    Dim strBuffer As String
    Dim FileHandle%

    strFilter = "Comma Seperated File (*.csv)|*.csv"
    CDMAIN.Filter = strFilter
    CDMAIN.ShowSave
    If CDMAIN.FileName <> "" Then
        strFileName = CDMAIN.FileName
        strText = Text1.Text
        FileHandle% = FreeFile

'''''''''''''''''''我很难转换以下代码行

        Open strFileName For Output As #FileHandle%
        MousePointer = vbHourglass
        Print #FileHandle%, strText
        MousePointer = vbDefault
        Close #FileHandle%
    End If

该功能将数据保存到excel文件

4

1 回答 1

0
    Open strFileName For Output As #FileHandle%
    MousePointer = vbHourglass
    Print #FileHandle%, strText
    MousePointer = vbDefault
    Close #FileHandle%

转换为 VB.NET 代码:

    Me.Cursor = Cursors.WaitCursor
    Using fs As New StreamWriter(strFileName, False)
        fs.WriteLine(strText)
    End Using
    Me.Cursor = Cursors.Default
于 2013-09-27T16:16:09.193 回答