|
-
Sep 25th, 2000, 06:17 PM
#1
Thread Starter
Addicted Member
I do I loop to load a file :
Code:
On Error GoTo BadPath
stat ("Opening " & Right$(a, Len(a) = 6) & " . . . ")
'-------------------------------------
ProgressBar1.Max= TotalOfLine
'-------------------------------------
Open Right$(a, Len(a) - 6) For Input As #1
Do Until EOF(1)
Line Input #1, temp$
'-------------------------------------
ProgressBar1.value = lineCompleted
'-------------------------------------
Editor = Editor & temp$ & vbCrLf
'-------------------------------------
'Wait HERE
'-------------------------------------
Loop
Close #1
txt = txt & vbCrLf
Editor.Visible = True
txt.Visible = False
Exit Sub
BadPath:
Editor.Visible = False
txt.Visible = True
stat ("*** Invalid file name")
Exit Sub
End Sub
I need that:
1) Do the program wait to write 1 millisecond
2) Count the number of line in the file
3) Count how many line is loaded in Editor.test
-
Sep 25th, 2000, 06:45 PM
#2
Fanatic Member
I am afraid you are going to have to explain yourself a little more. Anyway, here's a guess at what you want.
1. God knows why you would want to slow a program down by making it wait. One way to do this would be to use the Sleep function to sleep, for a millisecond. Other than that, you will have to use a loop and an API like QueryPerformanceCounter. See here
2. You want to count the lines in the file? While reading it in, or before hand. If you want to count the lines as you read them in, then just use a long variable as a counter. If you want to do it before hand, See here
3. It looks like you are loading all of the lines to Editor.test, so again, you can use a variable as a counter, just increment it every time you add a line.
Iain, thats with an i by the way!
-
Sep 25th, 2000, 06:47 PM
#3
To do a puase, use GetTickCount.
Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Sub Pause(Interval As Long)
Start = GetTickCount
Do While GetTickCount < Start + Interval
Loop
End Sub
And you can use it like:
Code:
'Pause for 1 ms
Pause 1
To get the number of lines, send the EM_GETLINECOUNT message.
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Sub Command1_Click()
Dim iLines As Long
iLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
MsgBox "There are " & iLines & " lines in the textbox"
End Sub
-
Sep 25th, 2000, 06:48 PM
#4
1:
Code:
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Sleep 1 '1 millisecond
2 and 3:
Take a look at this thread.
-
Sep 25th, 2000, 07:21 PM
#5
Lively Member
Megatron and Matthew Gates:
I understand that both of these are supposed to provide you with the same result. Am I right in thinking that if the system is slowed down by something or other Sleep 1 will cause the system to pause for more than a millisecond, whereas Megatron's code won't?!?!? Am I making sense? I was just trying to work out why Megatron had opted for the potentially more complicated method of creating a routine called Pause when there was already a perfectly usable API.
Explanation anyone? I think I'm confused
-
Sep 25th, 2000, 09:09 PM
#6
The sleep function is already counted in milliseconds, so 1 should just pause it for 1 millisecond.
The code Megatron gave is a little different, what his does is count up 1, and when it hits 1, it continues.
They basically do the same thing.
-
Sep 25th, 2000, 10:19 PM
#7
Thread Starter
Addicted Member
Ok thank'x a lot everyone ...
I have an other question ..
I use a INET control to get the source
of a file ex.:
Inet1.RemoteHost = URL1
text1.text=inet1.openURL
I just want to know the STATE ..
like 8 = connected
9 = Error
( just exemple, I really don't know .. )
and it is possible to find whit INET the REAL url ..
ex.:
www.procreation.cjb.net = http://procreation.citeglobe.com
thank'x again for your help :0)
-
Sep 25th, 2000, 10:40 PM
#8
Thread Starter
Addicted Member
I put the code into
Private Sub Inet1_StateChanged(ByVal State As Integer)
and the firt one return an empty value and
the sencond one return alway 0
-
Sep 25th, 2000, 10:46 PM
#9
Fanatic Member
Oop..i'm sorry about that. This should work:
Code:
Private Sub Inet1_StateChanged(ByVal State As Integer)
Text1.Text = State
End Sub
Gl,
D!m
PS. You would have to look up the states in the help files. I don't know them off the top of my head.
[Edited by Dim on 09-25-2000 at 11:48 PM]
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
|