måske du kan bruge noget fra dette. Example Sub Read_Files() Dim fso As New FileSystemObject, txtfile, _ fil1 As File, ts As TextStream Set txtfile = fso.CreateTextFile(\"c:\\testfile.txt\", True) MsgBox \"Writing file\" \' Write a line. Set fil1 = fso.GetFile(\"c:\\testfile.txt\") Set ts = fil1.OpenAsTextStream(ForWriting) ts.Write \"Hello World\" ts.Close \' Read the contents of the file. Set ts = fil1.OpenAsTextStream(ForReading) s = ts.ReadLine //hele teksten brug ReadAll MsgBox s ts.Close End Sub
Jeg ville nok gøre sådan, hvor \'Fil\' indeholder den fil, du vil læse (med mindre filen er meget stor):
Dim buffer As String
Private Sub Command1_Click() Open Fil For Input As 1 Line Input #1, Text1.Text Do Line Input #1, buffer Text1.Text = Text1.Text + vbCrLf + buffer Loop Until EOF(1) End Sub
Undskyld, sådan her skal den være; og husk at sætte tekstboksen til multiline:
Dim buffer As String
Private Sub Command1_Click() Open Fil For Input As 1 Line Input #1, buffer Text1.Text = buffer Do Line Input #1, buffer Text1.Text = Text1.Text + vbCrLf + buffer Loop Until EOF(1) End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.