Results 1 to 9 of 9

Thread: Expert ONLY

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208

    Wink

    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



  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    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!

  3. #3
    Guest
    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

  4. #4
    Guest
    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.

  5. #5
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Exclamation

    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

  6. #6
    Guest
    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.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    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)

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    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

  9. #9
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    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]
    Dim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width