vb中sleep函數(shù)如何使用

vb
小億
599
2023-09-26 22:44:34

在VB中,可以使用Threading.Thread.Sleep函數(shù)來(lái)使程序暫停指定的時(shí)間。

以下是使用Threading.Thread.Sleep函數(shù)的示例代碼:

Imports System.Threading
Module Module1
Sub Main()
Console.WriteLine("開始")
' 暫停程序執(zhí)行 5 秒鐘
Thread.Sleep(5000)
Console.WriteLine("結(jié)束")
End Sub
End Module

在上述示例中,我們使用Thread.Sleep(5000)來(lái)暫停程序的執(zhí)行5秒鐘。在這期間,程序會(huì)暫停并等待5秒鐘,然后繼續(xù)執(zhí)行后面的代碼。

請(qǐng)注意,Thread.Sleep的參數(shù)是以毫秒為單位的時(shí)間。

0