|
-
Aug 1st, 2000, 11:51 AM
#1
Thread Starter
Fanatic Member
Can someone plz explain how i would find out when 30lines have been writen to a text file? So every 30 lines, a msg box would pop up.
Thanx,
D!m
-
Aug 1st, 2000, 12:05 PM
#2
Hyperactive Member
mabye this
I know there has to be a better way to do it but if you get no replies then i guess a way is better then no way.
Dim sFirst, sSecond, sThird........, sThirty
Open "\file.txt" For Input As #7
Line Input #7, sfirst
If sthirty = "" Then
'sit on ur ass
else
Msgbox "There is something on line 30!"
Close #7
-RaY
VB .Net 2010 (Ultimate)
-
Aug 1st, 2000, 12:08 PM
#3
Lively Member
Maybe...
Write a function that does the writing to the file. It would have a for...next loop in with a counter to 30 and then message box would appear after the looping is done.
In the procedure that calls the function you could test to see if you need to write more or proceed when the function returns.
Just a suggestion.
-
Aug 1st, 2000, 12:35 PM
#4
Here's a way using mod which returns only the remainder of a division:
Dim x As Integer
Dim strMsg As String
Dim strInfo As String
x = 0 ' a counter
strMsg = "" ' message for messagebox
Open URFILE For Input As #1
' read the file until you get to EOF
Do Until EOF(1)
' if not at eof, then read line and increment counter
Line Input #1, strInfo
x = x + 1
If x Mod 30 = 0 Then
' x is evenly divisible by 30, ie a multiple
If strMsg = "" Then
' format the initial message
strMsg = "30 lines have been read"
Else
' format subsequent messages
strMsg = "30 more lines have been read"
End If ' strMsg = ""
' display the message box
MsgBox strMsg
End If ' mod(x)
Loop
Close #1
MsgBox "A total of " & Format(x, "0") & " lines were read"
-
Aug 1st, 2000, 12:40 PM
#5
_______
<?>
How are you writing the lines?
What is your code?
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 1st, 2000, 12:42 PM
#6
Frenzied Member
Re: mabye this
Originally posted by fallnwrld
I know there has to be a better way to do it but if you get no replies then i guess a way is better then no way.
Dim sFirst, sSecond, sThird........, sThirty
Open "\file.txt" For Input As #7
Line Input #7, sfirst
If sthirty = "" Then
'sit on ur ass
else
Msgbox "There is something on line 30!"
Close #7
A better approach would be to have a counter that increments every time you _write_ a RECORD.
dim I as long
dim sText as string
i=1
Open "file.txt" for output as #6
for i = 1 to endofprint
print #6, text
if i mod 30 = 0 then msgbox "30 (more) records have been processed."
next i
-
Aug 1st, 2000, 01:04 PM
#7
Code:
dim i as integer
dim LineStr as string
open Filename for input #1
do while not EOF(1)
line input #1, LineStr
i = i+1
if i = 30 then
msgbox "yo what up, this here file is at least 30 lines long!"
exit do
loop
close #1
-
Aug 1st, 2000, 01:13 PM
#8
Frenzied Member
Almost, Woss. You'll only report the first 30 lines, not every 30 lines.
-
Aug 1st, 2000, 01:18 PM
#9
_______
if i = 30 then
i = 1
msgbox "bla bla"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 1st, 2000, 01:43 PM
#10
Frenzied Member
Forgot your end if, Wayne.
-
Aug 1st, 2000, 04:23 PM
#11
Hyperactive Member
lol
Jhaus your a big help, has any of these techniques helped? Let us know!
-RaY
VB .Net 2010 (Ultimate)
-
Aug 1st, 2000, 04:41 PM
#12
Thread Starter
Fanatic Member
I did exactly what HeSaidJoe suggested...and i think it's probably the best way.
Thanx guys,
D!m
-
Aug 1st, 2000, 04:57 PM
#13
_______
<?>
it was wossname that did the trick with code....I just corrected an oversight it his/her code...
credit is not due me, but thanks for the thought.
All the best.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|