Solved

Stepping through file...

Posted on 2000-05-09
6
142 Views
Last Modified: 2010-05-02
Hi guys,

I need to read a file line by line to get some test logins and passwords e.g line one is

login password

I'm posting this to a script in a form using Inet.execute, now here's the prob, it works fine, but what I need to know is how read one line, then process this to the form, then read the next line and process this to the form, etc etc, at the moment it's just looping through all the way to the last line and then only processing that line, if I try to include the inet.execute every loop it says the last process is still executing.

How I can I execute each line in the file? Furthermore, can I use a timer somehow to get this function to go through the file again after a certain period i.e after 1 second, after 30 seconds, etc? without having to click the command button again? Here;s my code, thanks for any help.

Private Sub cmdPOST_Click()
   picTic.Visible = True
   txtData.Text = ""
   
   Dim fnum As Integer
   Dim file_name As String
   Dim got_file As Boolean
   Dim txt As String
   
   Dim i As Integer
   Dim sArray As Variant
   
    ' Get the file's name.
    file_name = App.Path
    If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
    file_name = file_name & "logins.txt"
     
    ' Open the file.
    fnum = FreeFile
    On Error Resume Next
    Open file_name For Input As fnum
    got_file = (Err.Number = 0)
    On Error GoTo 0

    If got_file Then
        ' Read the text.
               Do Until EOF(fnum)
       
            Input #fnum, txt
            sArray = Split(txt)
            txtRemotePath.Text = "MNO=" & sArray(0) & "&PWD=" & sArray(1) _
            & "&BSB=NTV25"
     Loop
   Inet1.Execute txtURL.Text, "POST", txtRemotePath.Text, _
   "Content-Type: application/x-www-form-urlencoded"
   Text1.Text = Text1.Text & "yeah"
        ' Close the file.
    Close fnum
    End If
   
End Sub
0
Comment
Question by:GnatMan
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2795284
You can check the StillExecuting property to see if the control is busy with a earlier assignment. Perhaps you could implement a Do..Loop block after the Execute call like this

  'Place the Execute call here
  Do While Inet1.StillExecuting
    DoEvents
  Loop
  'The Inet control is free for next action here
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2795290
use the Line Input statement, e.g.
Line Input #FileNumber, A$

where filenumber is your file number and A is a string to receive the line from the file...then process that one line and perform the loop until EOF
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2795292
sorry i misread the question
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2795300
vbmaster is correct...you need to check that state...b/c when you use execute method it processes your request asynchronously which means it returns control back to your app right away...
0
 
LVL 7

Accepted Solution

by:
Vbmaster earned 23 total points
ID: 2795306
Just add a Timer control and set the Interval to 30000 (in case of 30 sec) or 60000 in case.. humm..

Inside the timer_timer event you can put code like...

  Private Sub Timer1_Timer

    Static Inside As Boolean
    If Inside Then Exit Sub
    Inside = True

    Call cmdPOST_Click()

    Inside = False

  End Sub

The static Inside varaible is probably really important here because sometimes maybe the cmdPost code will take more than 30sec (or whatever interval the timer is on) and you do not want two or more timer events to be executed simultaneous, that is just begging for trouble.

The Interval property of the Timer control is limited to 65535 ms, if you need a interval longer than 1 minute you can set the Interval to 60000 ms (1 minute) and then add a static counter inside the timer event. Increase the value with 1 every time the event is fired, and then if the timer equals the number of minutes you want to go between the calls to the code then set the variable to zero and run the cmdPOST code.
0
 

Author Comment

by:GnatMan
ID: 2795493
Thanks for all the help and the quick replies VBmaster and Azrasound, you guys are awesome! It really helped, got it working now. Cheers!
Nathan
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question