|
-
Nov 24th, 2000, 05:23 AM
#1
Thread Starter
Hyperactive Member
Hey, how do you get the FIRST character of a file,
do something with it, get the SECOND, do something with it, get the THIRD, do something with it, get the 4th and do something with it..
then skip to the NEXT LINE
and repeat the process?
Like:
FILE:
altl
oauw
notk
It would get
A, and do something with it
L, do something
T, do something
L, do something
SKIP
o, do something
A, do something
U, do something
W, do something
SKIP
etc.
THANKS ALOT
-
Nov 24th, 2000, 05:58 AM
#2
Lively Member
Here, Try this...
Code:
'// Warning: This code has not been tested!!!
'// I wrote it just to give you an idea.
Dim iFileNum As Integer
Dim sFileName As String
Dim iFileSize As Long
Dim iPos As Long
Dim iSkipByte As Integer
'// These are the Characters (bytes postion)
'// we want to skip
iSkipByte = 5
'// Replace the quoted line with your file
sFileName = "C:\netlog.txt"
'// Get file size
iFileSize = FileLen(sFileName)
'// Open file
iFileNum = FreeFile
Open sFileName For Binary As #iFileNum
'// Process file
For iPos = 1 To iFileSize
'// Check if byte position should be processed
If iPos Mod iSkipByte > 0 Then
'// Read byte iPos
Get iFileNum, iPos, sBuffer
End If
'// Do something with sBuffer's content
'// (Your code here)
Next iPos
-
Nov 24th, 2000, 06:10 AM
#3
Lively Member
hi,
if reading a text file then use FileSystemObject Project|References select Microsoft scripting runtime
Public objFile As New Scripting.FileSystemObject 'Object for File
Public objFileRead As Scripting.TextStream 'Object for File Opening/reading/writing
Private Sub Form_Load()
sFileName = "C:\test.txt"
Set objFileRead = objFile.OpenTextFile(sFileName, ForReading)
While Not objFileRead.AtEndOfStream
sdata = objFileRead.Read(1)
MsgBox sdata
Wend
End Sub
-
Nov 24th, 2000, 03:15 PM
#4
Thread Starter
Hyperactive Member
Hey, thanks..
But is there a way to determine what LINE we are reading from?
cause i have a file like this:
<Example>
lrkaovmr0393mwpdl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
ffghgfhgadgf54tydfhm56755y5n45]p][./"//.r0393mwpdl[./"//.d34
gdgdfgdfg4643g5dl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
lrkaovmr0393mwpdl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
ffghgfhgadgf54tydfhm56755y5n45]p][./"//.r0393mwpdl[./"//.d34
gdgdfgdfg4643g5dl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
lrkaovmr0393mwpdl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
ffghgfhgadgf54tydfhm56755y5n45]p][./"//.r0393mwpdl[./"//.d34
gdgdfgdfg4643g5dl0g9b\]p][./"//.r0393mwpdl0g9b\]p][./"//.d34
something like that..
and i need to record what character in each line.. it is recording (or what the sBuffer's content was located)
i need like Character 10, line 5 , then the character that is there.
It may be simple.. but i can't really edit code that i am not sure how it really WORKS in the first place...
i know how it works, but like, not what all methods of u using.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|