VB 6 Pro Internet Logging + Processing

Hi,
I was wondering if anyone could please help me with the following program.
Thanks,this is VERY important to me.
Thankyou.
A program that logs the users connection and disconnection to & from the internet (automatically) showing when the user was on (date & time) and how long for.The time being in 24Hour form.
The program would then calculate the total time the user was online converting that into Hours,Minutes,Seconds after each session.
It will also allow the user to state how much they get charged for each hour online.
The Program will also allow the user to set time prompts (alarms) for certain times/durations where when met as reminders on the screen with
custom message.E.g 13.00 hours "Go for Dinner".
This will save this information in a log file like the following.

Date            LogOn      LogOff      Duration      Cost
~~~            ~~~~~      ~~~~~~      ~~~~~~~~      ~~~~
1/1/2000      10.05      11.10      1H 5Minutes      $2.71
2/1/2000      12.00      13.00      1H            $2.50
30/1/2000       7.00       9.00      2H            $5.00
31/1/2000      18.00      20.00      2H            $5.00

END
                  -------------------------------
                        6H 5Minutes      $15.21
                  -------------------------------

Thanks
Dave Steers
dsteersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ViniTCommented:
Do you want us to write you this program?
0
sdland1Commented:
ive seen something like this at http://lightning.prohosting.com/~shell123
0
dsteersAuthor Commented:
ViniT,
No I don't,(unless you want to).
All I am asking for is a helping hand along the road to success.
Thanks
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

dsteersAuthor Commented:
sdland1,
Had a look but couldn't find it.
Can you be more specific ??
Thanks
0
dsteersAuthor Commented:
Can You Guys Help Me Out ????

Thanks
Dave Steers
0
dsteersAuthor Commented:
Adjusted points to 200
0
dsteersAuthor Commented:
Increased Points to 200
??????????????????????????????????????
0
LewyCommented:
Try this to find out about the connection:
Public Declare Function InternetGetConnectedState _
    Lib "wininet.dll" (ByRef lpdwFlags As Long, _
    ByVal dwReserved As Long) As Long

    Public Const INTERNET_CONNECTION_MODEM As Long = &H1
    Public Const INTERNET_CONNECTION_LAN As Long = &H2
    Public Const INTERNET_CONNECTION_PROXY As Long = &H4
    Public Const INTERNET_CONNECTION_MODEM_BUSY As Long = &H8
    Public Const INTERNET_RAS_INSTALLED As Long = &H10
    Public Const INTERNET_CONNECTION_OFFLINE As Long = &H20
    Public Const INTERNET_CONNECTION_CONFIGURED As Long = &H40
 
0
dsteersAuthor Commented:
Yes ??
That tells me what type of connection.
??
0
LewyCommented:
How would you handle situations with the user logged on through midnight?
The log uses non standard time format and is difficult to read.
How will the Alarms be entered? A grid?

Restate Specifications with suggestions:
The program logs the users connection and disconnection to & from the Internet showing when the user was logged on (date & time) and how long. The time being in 24Hour form (hh:mm). The program would then calculate the total time the user was online converting that into Hours and Minutes after each session. It will also state the amount they are charged for a session online based on an hourly rate.
The program will save this information in a log file like the following.

Date       LogOn Duration   Cost
~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~
01/01/2000 10:05 01:05    $ 2.71
02/01/2000 12:00 01:00    $ 2.50
30/01/2000 07:00 02:00    $ 5.00
31/01/2000 18:00 02:00    $ 5.00
--------------------------------
Total            06:05    $15.21
--------------------------------

The Program will also allow the user to set alarms for certain times or durations. When the criteria is met a reminder will appear on the screen with a custom message. E.g. 13.00 hours "Go for Dinner".

A Timer will be used to evaluate the durations and process alarms. The Timer would determine the minimum billing resolution (6 Seconds or one ten of a minute).  

When the program is started, It will Open for Output (this will kill a file of the same name) and Print the Header to the Log file. It will Close the Log file.
In the Timer Event when it has been determined that the connection is made, it will save the Date and Time in a Static Variable as the Log On Time (LogOnTime = Date + Time). When it has been determined that the connection is no longer made, it will Open the log file for Append and Print the LogOnTime using a format of "dd/mm/yyyy hh:mm ", the difference between the current time + date and LogOnTime using a format of “hh:mm   “, and the calculated amount. It will then close the log file.
When it is determined that the log file should be closed, the log file should be Opened for Append and the Footer with the Total Time and Amount should be Printed. Close the Log file.

The Timer will also compare the current date + time to each of the dates + times entered in the Alarm Table, when the Alarm date + Time is less than or Equal to the current Date + time then display the Message. The Alarm information would then be removed or mark as processed.

Can you code it with the above suggestions or do you need specific code examples? If so, what areas do you need help in?
0
dsteersAuthor Commented:
Adjusted points to 250
0
dsteersAuthor Commented:
Lewy,
You put it well my friend.
This is exactly what I want to happen, but I am unsure how even to start.
I know how to get the current Date and Time using the Get function,but from there I am lost.
I would appreciate it very very much if you could please help me some more.

Thankyou
Dave Steers
0
LewyCommented:
Here is a start:

    Dim SessionTime As Date
    Dim AlarmList As New Collection
    Dim AlarmListText As New Collection

Private Sub Form_Load()
    Dim LogFileNum As Integer
    LogFileNum = FreeFile
    Open App.Path & "\LogFile.log" For Output As #LogFileNum
    Print #LogFileNum, "Date       LogOn Duration   Cost "
    Print #LogFileNum, "~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ "
    Close #LogFileNum
End Sub

Private Sub Timer1_Timer()
    Static LogOnTime As Date, CurrentTime As Date, TestConnectOld As Boolean
    Dim LogFileNum As Integer
    Dim AlarmEvent
   
    CurrentTime = Date + Time
    If TestConnection <> TestConnectOld Then
        TestConnectOld = TestConnection
        If TestConnection Then
            LogOnTime = CurrentTime
        Else
            SessionTime = SessionTime + (CurrentTime - LogOnTime)
            LogFileNum = FreeFile
            Open App.Path & "\LogFile.log" For Append As #LogFileNum
            Print #LogFileNum, Format(LogOnTime, "dd/mm/yyyy hh:mm ") _
                            & Format(CurrentTime - LogOnTime, "hh:mm    ") _
                            & Format((CurrentTime - LogOnTime) * 24 * Val(ConnectRate), "$00.00")
            Close #LogFileNum
        End If
    End If
   
    For AlarmEvent = AlarmList.Count To 1 Step -1
        If AlarmList.Item(AlarmEvent) <= CurrentTime Then
            MsgBox (AlarmListText.Item(CStr(AlarmList.Item(AlarmEvent))))
            AlarmListText.Remove (CStr(AlarmList.Item(AlarmEvent)))
            AlarmList.Remove (AlarmEvent)
        End If
    Next AlarmEvent
End Sub

Private Sub Command1_Click()
    Dim T As Date
    T = DateAdd("s", 15, Date + Time)
    AlarmList.Add Item:=T
    AlarmListText.Add Item:="Take a break!", Key:=CStr(T)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim LogFileNum As Integer
    LogFileNum = FreeFile
    Open App.Path & "\LogFile.log" For Append As #LogFileNum
    Print #LogFileNum, "-------------------------------- "
    Print #LogFileNum, "Total            " _
                            & Format(SessionTime, "hh:mm    ") _
                            & Format(SessionTime * 24 * Val(ConnectRate), "$00.00")
    Print #LogFileNum, "-------------------------------- "
    Close #LogFileNum
End Sub

Private Function TestConnection() As Boolean
    ' TestConnection uses the Function InternetGetConnectedState
    ' to determine if the user is connected.
    TestConnection = TestConnect.Value 'checkbox for testing
End Function

If you need more, let me have you e-mail address.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dsteersAuthor Commented:
Hi Lewy,
       It's Dave Steers here.
My e-mail address is
     dave@midcoast.com.au

Just send a message so that I can get your e-mail and send you some questions too (for EE points ofcourse :).
Thanks

Dave Steers

0
dsteersAuthor Commented:
Lewy,
      Just a quick question.
      I plan to put the Date,Login Time,Log-out Time,Duration & Cost into a listbox (with the appropriate columns - mentioned above).

To tell exactly when a user is connected to the Internet will I have to use a timer that is set to a 1 second interval.
This time will be shown in the listview table under the column (Login) and (Log-out),exactly like your diagram except in the listview report format.
How exactly do I do this.
E-mail me if preferable & we'll take it from there. :)
Thanks

Dave Steers
0
dsteersAuthor Commented:
There we go
Thanks
Dave Steers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.