April 27th, 2002, 10:03 AM
|
#1 (permalink)
| | Senior Member
Join Date: Jan 2002 Location: England
Posts: 817
|
Hey
Recently my ISP has been really shady and told me off for being online downloading for more than 16 hours(dialup)....I thought it was anytime
Anyway....i would really like it if someone could help me program a ISP timer. I would really like to do it stages if possible coz im very bad a VB
Like this sort of stage set up of programming:
-Make a simple timer
-Add a ISP online timer like when it connects, the time starts(if possible)
-Add a save time code so that it will caluculate the time i have been online all day even if i reboot it in the middle
The reason i want a save time code is becuase my ISP disconnects me every 2 hours and the windows dial up time resets
Now i will understand if you don't have a clue what im on about and i will try to explain it better if you ask
Aternatively if possible you could create a timer yourself and we could add the code for the extra's
I really hope you can help! |
| |
April 27th, 2002, 06:52 PM
|
#2 (permalink)
| | Senior Member
Join Date: Jan 2002 Location: England
Posts: 817
|
^bump^ anyone?  not even with a little help? |
| |
April 28th, 2002, 05:35 PM
|
#3 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
1. Timer.
Form with label lblDisplay, buttons cmdStart, cmdStop Code: Dim tStart As Date
Dim bRunning As Boolean
Private Sub cmdStart_Click()
bRunning = True
tStart = Now()
' begin timer
TimerProc
End Sub
Private Sub cmdStop_Click()
bRunning = False
' stop timer
End Sub
Sub TimerProc()
While bRunning
lblDisplay.Caption = Int(Now() - tStart) & " days " & Format(Now() - tStart, "hh:mm:ss")
'continue timer
Application.Wait (Now + TimeValue("0:00:01"))
DoEvents
Wend
End Sub Of course, this isn't the best way to do it. Far better would be to use a timer control, or a timer object. See below. |
| |
April 28th, 2002, 05:39 PM
|
#4 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
1a. Timer object. I make a reference to the "vbAccelerator VB6 Subclassing and Timer Assistant" object, %SystemRoot%\System32\SSubTmr6.dll
frmTimer (label lblDisplay, buttons cmdStart, cmdStop): Code: Dim tStart As Date
Dim ct As clsTimer
Private Sub cmdStart_Click()
tStart = Now()
' begin timer
ct.ct.Interval = 1000
End Sub
Private Sub cmdStop_Click()
bRunning = False
' stop timer
ct.ct.Interval = 0
End Sub
Sub TimerProc()
lblDisplay.Caption = Int(Now() - tStart) & " days " & Format(Now() - tStart, "hh:mm:ss")
End Sub
Private Sub UserForm_Initialize()
Set ct = New clsTimer
Set ct.ct = New CTimer
End Sub Class Module clsTimer: Code: Public WithEvents ct As SSubTimer6.CTimer
Private Sub ct_ThatTime()
frmTimer.TimerProc
End Sub |
| |
April 28th, 2002, 06:35 PM
|
#5 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
Now what? Well, to get it to start on dial-up, we need a way to sniff Windows to see whether it has a DUN connection open. Unfortunately, the best way for this differs between Windozes, so we'll need to know your Windows version. |
| |
April 28th, 2002, 06:56 PM
|
#6 (permalink)
| | Senior Member
Join Date: Jan 2002 Location: England
Posts: 817
|
hey thanks for the help, i have windows xp home btw dunno if you want more info on the build or something? |
| |
April 28th, 2002, 07:37 PM
|
#7 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 1,542
|
OK, there's only 1 way to do this. In 9x we could make a registry call, but the NT kernel isn't as nice. So you can either use the Ras API calls (we want RasEnumConnections and then RasGetConnectStatus) Or you can cheat & use ipconfig but that's messy. So...RasEnumConnections. Well, I did a google on rasapi32 vb and got quite a few useful hits; the first one is on codeguru at http://www.codeguru.com/vb/openfaq/comments/113.shtml and should work under XP (hopefully)
So call his IsConnected function at say 10-second intervals using a second instance of the timer (at 10000 interval) and when it returns True start the original timer, then get that to check IsConnected maybe on each call or maybe only every 10 seconds. Can't write the code right now but you should be able to do that OK. |
| |
April 29th, 2002, 03:57 PM
|
#8 (permalink)
| | Senior Member
Join Date: Jan 2002 Location: England
Posts: 817
|
i have done that, i got some help of another vb guru and i added it to your code and i have a working( i think) program!
thanks for you time  |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |