Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Need Help About Vb6 Function To Vb.net

Visual Basic 4 / 5 / 6 VB.NET timer

  • Please log in to reply
2 replies to this topic

#1 yonghan

yonghan

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 103 posts

Posted 12 July 2012 - 08:15 AM

Hi all,i got a vb6 function like this

Private Sub pause(ByVal interval As Variant)
Dim Current As Variant

Current = Timer
Do While Timer - Current < Val(interval)
	 DoEvents
Loop
End Sub

and i tried convert into this way :

Private Sub pause(ByVal interval As Single)
	 Dim newDate As Date
	 newDate = DateAndTime.Now.AddSeconds(interval)
	 While DateAndTime.Now.Second <> newDate.Second
		 Application.DoEvents()
	 End While
End Sub

It doesn't works.Could someone help me pointing where is the wrong?Thanks a lot guys.. :)
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 12 July 2012 - 10:47 AM

Is 'interval' variable value in seconds?

However, in your conversion code, you used 'not equal' where as in original code it was less than. I think the code should be as

Private Sub pause(ByVal interval As Single)
        Dim newDate As Date
        newDate = DateAndTime.Now.AddSeconds(interval)
        While DateAndTime.Now.Second < newDate.Second
            Application.DoEvents()
        End While
    End Sub

  • 1

#3 yonghan

yonghan

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 103 posts

Posted 17 July 2012 - 07:58 AM

Hi,i have tried it.it works though but doesn't work as i expected.Actually i'm trying to create autoreply for messenger,i can retrieve new message but when i put it on a listbox,it gives me and extra item like this.Do you mind to help check my code?Thanks. :)

Posted Image
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download