home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 3103
Discussions: 188,375, Posts: 2,243,441, Members: 232,603
Old April 27th, 2002, 10:03 AM   Digg it!   #1 (permalink)
Senior Member
 
Linkin' Park's Avatar
 
Join Date: Jan 2002
Location: England
Posts: 817
VB:ISP Timer

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!

Linkin' Park is offline   Reply With Quote
Old April 27th, 2002, 06:52 PM     #2 (permalink)
Senior Member
 
Linkin' Park's Avatar
 
Join Date: Jan 2002
Location: England
Posts: 817
^bump^ anyone? not even with a little help?

Linkin' Park is offline   Reply With Quote
Old April 28th, 2002, 05:35 PM     #3 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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.

strangerstill is offline   Reply With Quote
Old April 28th, 2002, 05:39 PM     #4 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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
strangerstill is offline   Reply With Quote
Old April 28th, 2002, 06:35 PM     #5 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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.
strangerstill is offline   Reply With Quote
Old April 28th, 2002, 06:56 PM     #6 (permalink)
Senior Member
 
Linkin' Park's Avatar
 
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?
Linkin' Park is offline   Reply With Quote
Old April 28th, 2002, 07:37 PM     #7 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
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.
strangerstill is offline   Reply With Quote
Old April 29th, 2002, 03:57 PM     #8 (permalink)
Senior Member
 
Linkin' Park's Avatar
 
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
Linkin' Park is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2881)
The United States Debt (20)
Looks like Burris will get his Sena.. (7)
Upgrading RAM (5)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (437)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Titan quest and Immortal Throne, an.. (17)
Recent Discussions
Folderchat Weekday thread (438)
Help with an Ati Radeon HD 4850.. (23)
Laptop waking up itself (0)
CPU wont boot (3)
Best digital camera for under 2.. (13)
Building first computer, will t.. (2)
get this error, "res://C:\.. (73)
Problem with boot and motherboa.. (0)
MS to offer free Windows 7 upgr.. (1)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 07:45 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28