How to create delay in VB.NET

2 Answers

0 votes
Imports System
Imports System.Threading
 
Public Class Program
    Public Shared Sub Main()
        Try
            Console.WriteLine("Counting...")
             
            Dim milliseconds As Integer = 3000
            Thread.Sleep(milliseconds) ' will lock the thread
             
            Console.WriteLine("Lift Off")
        Catch e As Exception
            Console.WriteLine(e.ToString())
        End Try
    End Sub
End Class
 
 
 
' run:
'
' Counting...
' Lift Off
'

 



answered Jul 11, 2015 by avibootz
edited Apr 13, 2024 by avibootz
0 votes
Imports System
Imports System.Threading
 
Public Class Program
    Public Shared Sub Main()
        Try
            Console.WriteLine("Counting...")
             
            Thread.Sleep(CType(TimeSpan.FromSeconds(3).TotalMilliseconds, Integer))
             
            Console.WriteLine("Lift Off")
        Catch e As Exception
            Console.WriteLine(e.ToString())
        End Try
    End Sub
End Class
 
 
 
' run:
'
' Counting...
' Lift Off
'

 



answered Jul 11, 2015 by avibootz
edited Apr 13, 2024 by avibootz
...