Gegevens opslaan

Status
Niet open voor verdere reacties.

berry14

Gebruiker
Lid geworden
25 apr 2008
Berichten
164
Heey,

Weet iemand waarom dit fout gerekend wordt?
Of heeft iemand een code die WEL werkt?
Ik heb VB 2008 Express edition.


Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hFile As Long
        Dim sFilename As String

        sFilename = "c:\demo.txt"

        'obtain the next free file handle from the 
        'system and and save the text box contents
        hFile = FreeFile()
   [U][B][COLOR="red"]Open sFilename For[/COLOR][/B][/U] Output As #hFile
      Print [U][B][COLOR="Red"]#[/COLOR][/B][/U]hFile, Textbox1.Text
   Close [U][B][COLOR="red"]#[/COLOR][/B][/U]hFile

    End Sub
End Class

B.v.d.!
 
Dit is oude vb6 code.

VB2008 heeft een file/io TextWriter class speciaal om makkelijk weg te schrijven.

Code:
        Dim File As System.IO.TextWriter = New System.IO.StreamWriter("c:\temp\mytext.txt", IO.FileMode.Create)
        File.WriteLine(Label1.Text)
        File.Close()
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan