當前位置:編程學習大全網 - 編程軟體 - VB基礎知識

VB基礎知識

新建壹個窗體,上面添加壹個command和壹個timer

代碼如下

Dim Pathname As String, Filename As String, Delay As Integer

Private Sub Command1_Click()

Pathname = "e:\vb" '目錄名

Filename = "1.bat" '文件名

If Dir(Pathname, vbDirectory) = "" Then

MkDir Pathname

End If

If Right(Pathname, 1) <> "\" Then Pathname = Pathname & "\"

Open Pathname & Filename For Output As #1

Print #1, "@echo off"

Print #1, "......" '這裏面添加bat文件內容,壹行壹行寫

Close #1

Timer1.Interval = 1000 '註意這裏應該是1000,即1秒鐘計時壹次,當然也可以提高精度比如500毫秒計時壹次,註意最高精度為15毫秒,壹般建議1000毫秒

Delay = 10 '這裏是延遲時間,delay*timer1.interval 為延遲毫秒數,10*1000=10000即10秒,當然100秒1000秒隨意

Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

If Delay > 0 Then

Delay = Delay - 1

Else

Shell Pathname & Filename

Timer1.Enabled = False

End If

End Sub

包含創建和倒計時打開的步驟

  • 上一篇:如何學好數控CNC?
  • 下一篇:using namespace std是什麽意思啊
  • copyright 2024編程學習大全網