27 Maret 2012

Visual Basic : Membaca dan Menulis File Text



1. Menulis Ke File Text

Dim LocTextFile As String
LocTextFile = “C:\windows\SvAdd.txt”

Open LocTextFile For Output As #1 ‘Buka file text
Print #1, “Server_Name” ‘Modify Baris Pertama”
Print #1, “Database_Name” ‘Modify Baris Kedua
Print #1, “User” ‘Modify Baris Ketiga
Print #1, “Pwd” ‘Modify Baris Keempat
Close #1
2. Membaca dari File Text


Dim LocTextFile As String
Dim ServerAddress As String
Dim DatabaseName As String
Dim UserID As String
Dim PwdSql As String
LocTextFile = “C:\windows\SvAdd.txt”
Open LocTextFile For Input As #1 ‘Buka file text
Line Input #1, ServerAddress ‘Baca Baris Pertama
Line Input #1, DatabaseName ‘Baca Baris Kedua
Line Input #1, UserID ‘Baca Baris Ketiga
Line Input #1, PwdSql ‘Baca Baris Keempat
Close #1 ‘Tutup File file text
Selamat Mencoba !!

sumber : link