C
CSharp
C++
Java
Visual Basic
HTML - CSS
Android
Asp
Asp.Net
Php
Python
JavaScript
SQL
XML
Assembly
ActiveX
API
Code Snippets
Database
Files Directories Drives
Forms
Graphics Games
Multimedia
Strings
Windows and Controls
More...
Visual Basic > Files Directories Drives sample source codes
Visual Basic Code > Working with textfiles (Open etc)
Working with textfiles (Open etc) 'open a textfile on disk into a textbox 'make a Form with a TextBox (multiline = True) 'and two commandbuttons 'put the next code on the appropiate places Sub Command1_Click() Call GetFile("c:\autoexec.bat") End Sub Private sub GetFile(FileName$) Dim nFilenumber% Dim tmpLine$ Text1.Text = "" nFilenumber = FreeFile Open FileName$ For input as #nFilenumber Do While Not EOF(nFileNumber) Input #nFileNumber, tmpLine Text1.Text = Text1.Text & tmpline Loop Close #nFileNumber End Sub 'save the content of a textbox into a file on disk Sub Command2_Click() Dim answer$ answer$ = InputBox("Which name will you give the file?") If answer$="" then Exit Sub Call SaveFile(answer$) End Sub Private sub SaveFile(FileName$) Dim nFilenumber% nFilenumber = FreeFile Open FileName$ For Output as #nFilenumber Print #nFileNumber, Text1.Text Close #nFileNumber End Sub Return
Privacy Policy
|
Contact
|
Advertising
|
Link to Us
|
Directory