Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,037 members, 7,814,539 topics. Date: Wednesday, 01 May 2024 at 02:37 PM

I Need Help With This Vb Snippet. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / I Need Help With This Vb Snippet. (1444 Views)

How To Send SMS Using Asp.net/vb.net / Fingerprint Authentication In Vb.net Application / Post Ur Vb 6.0 Questions Here (2) (3) (4)

(1) (Reply) (Go Down)

I Need Help With This Vb Snippet. by Nobody: 1:47pm On Jun 15, 2009
Hello Visual Basic Gurus in the house.

I want to write a small app to stay alive forever until you shut down and run a particular function every 30 mins
the function is supposed to query a website for it's content.

I have the code ready but i have no clue as to how to setup a function or timer
here is the code meant to go inside our dear function, or method, whichever.

Dim objHttp

Set objHttp = CreateObject("Msxml2.ServerXMLHTTP"wink
objHttp.Open "GET", "http://www.thewebsite.com/url.php", False

objHttp.Send
Dim Text1
Text1 = objHttp.ResponseText
Set objHttp = Nothing

msgbox Text1

now that code shud be in a method/function to be called every 30 mins


I decided vb will be best cos i dont need to start another class on installing packages and all that.

thanks in advance.
Re: I Need Help With This Vb Snippet. by Kobojunkie: 5:13pm On Jun 15, 2009
Re: I Need Help With This Vb Snippet. by Nobody: 6:02pm On Jun 15, 2009
Thanks for that link, am sure i googled earlier and visited that link,
but the issue i have is this.

this looks more like a function to me, how do i call it
and how do i wrap my code into this EFFICIENTLY.

' Visual Basic 6.0
Public Function TimerOn(Interval As Integer)
If Interval > 0 Then
' Start the timer.
Timer1.Interval = Interval
Else
' Stop the timer.
Timer1.Interval = 0
End If
End Function

i came up with this


' Visual Basic 6.0


Public Function TimerOn()

Dim objHttp

Set objHttp = CreateObject("Msxml2.ServerXMLHTTP"wink
objHttp.Open "GET", "http://www.thewebsite.com/url.php", False

objHttp.Send
Dim Text1
Text1 = objHttp.ResponseText
Set objHttp = Nothing

msgbox Text1

End Function


how do i cal this function and how do i set the timer,
the link only shows how to start and stop the timer i guess.
Re: I Need Help With This Vb Snippet. by Nobody: 12:47am On Jun 16, 2009
Hey webdezi, why did you not tell me about this. i code vb 6 better than all my php/mysql/ajax o!
but maybe not as good as lucky and kobojunkie sha! i don take all my vb chop javascript finish!

Dont answer me, i dont usually come to this board like that, hi kobojunkie, it has been awhile. . .
But this is my second home now after webmasters as i now have to moderate this board.

When we see in chat, we will continue. . . .to start and stop your timer, just enable and disable it

timer1.enabled=false 'disable
timer1.enabled=true 'enable

see ya later guy
Re: I Need Help With This Vb Snippet. by Kobojunkie: 2:02am On Jun 16, 2009
It has been a while since I have coded in VB6

On Program load, Set Timer interval to something like 30000. Then
In the Timer event handler


Private Sub mytimer_Timer()
//add code you want to run every 30 minutes
CodeToRunEvery30minutes()

End Sub

Private Sub CodeToRunEvery30minutes()
Dim objHttp
   
Set objHttp = CreateObject("Msxml2.ServerXMLHTTP"wink
objHttp.Open "GET", "http://www.thewebsite.com/url.php", False

objHttp.Send
Dim Text1
Text1 = objHttp.ResponseText
Set objHttp = Nothing

msgbox Text1
End Sub
Re: I Need Help With This Vb Snippet. by Nobody: 5:42am On Jun 16, 2009
Yeah right kobojunkie, i think all this should help him better.
Re: I Need Help With This Vb Snippet. by Nobody: 12:56pm On Jun 17, 2009
thanks guys for ur contributions,

timer1.enabled=false 'disable
timer1.enabled=true  'enable

that will disable and enable timer as i can see, i dont think i need to disable or enable timer

what i need is something like making the timer go to bed, u know, doze off grin.

in python, it looks something like


def CodeToRunEvery30minutes()
     #yea, i know this is VB, just an example.
      Dim objHttp
      Set objHttp = CreateObject("Msxml2.ServerXMLHTTP"wink
      objHttp.Open "GET", "http://www.thewebsite.com/url.php", False

      objHttp.Send
      Dim Text1
      Text1 = objHttp.ResponseText
      Set objHttp = Nothing

      msgbox Text1


def startApplication()
      time.sleep(1800)                     #this makes the method to sleep only to wake up after 30 minute to run the next codeToRunEvery30Minutes()
      CodeToRunEvery30minutes()
      startApplication()                    #loops forever, since we have embedded it in itself

startApplication()                          #this starts the method defined above

but getting that logic 2 gether in one piece is my headache.
I dont want to start reading intro to VB.

(1) (Reply)

Coding From Scratch Or Using Bootstrap, which way? / How Do You Write Programs With Your Mobile Phone / I Need An MQL4 Programmer For A Quick Job

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.