1
Programming / read char by char....
« pada: April 23, 2009, 10:04:43 AM »
ni source codenya :
Option Explicit
Dim bytes() As Byte
Dim file_length As Long
Dim txt As String
Private Sub cmdRead_Click()
Dim file_name As String
Dim i, fnum As Integer
file_name = "boot.ini"
file_length = FileLen(file_name)
fnum = FreeFile
ReDim bytes(1 To file_length)
Open file_name For Binary As #fnum
Get #fnum, 1, bytes
Close fnum
For i = 1 To file_length
If Not Asc(bytes(i)) = 10 Or Asc(bytes(i)) = 13 Then
txt = txt & Chr(bytes(i))
End If
If bytes(i) = 10 Then
txt.Text = txt.Text & txt
txt = ""
End If
Next i
End Sub
pertama,siapin formnya
tambahin 1 command button am 1 textbox
command buttonnya dikasih nama cmdRead, textboxnya dikasih nama txt
g pke bwt bc file boot.ini,klo ga file .txt,tp msh agak error seh klo bc .txt hehe
msh byk yg salah neh hehe
maklum msh belajar
ada yg tau cr bc file .doc ke textbox ?
smg bermanfaat

Option Explicit
Dim bytes() As Byte
Dim file_length As Long
Dim txt As String
Private Sub cmdRead_Click()
Dim file_name As String
Dim i, fnum As Integer
file_name = "boot.ini"
file_length = FileLen(file_name)
fnum = FreeFile
ReDim bytes(1 To file_length)
Open file_name For Binary As #fnum
Get #fnum, 1, bytes
Close fnum
For i = 1 To file_length
If Not Asc(bytes(i)) = 10 Or Asc(bytes(i)) = 13 Then
txt = txt & Chr(bytes(i))
End If
If bytes(i) = 10 Then
txt.Text = txt.Text & txt
txt = ""
End If
Next i
End Sub
pertama,siapin formnya
tambahin 1 command button am 1 textbox
command buttonnya dikasih nama cmdRead, textboxnya dikasih nama txt
g pke bwt bc file boot.ini,klo ga file .txt,tp msh agak error seh klo bc .txt hehe

msh byk yg salah neh hehe

ada yg tau cr bc file .doc ke textbox ?

smg bermanfaat

