真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

包含vb.net內(nèi)部定時(shí)器的詞條

vb.net如何在windows控制臺(tái)下使用定時(shí)器

控制臺(tái)調(diào)用Timer和窗體是類似的。首先在項(xiàng)目引用里面加入System.Windows.Forms程序集,然后在代碼頂部引入命名空間:

創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括西寧網(wǎng)站建設(shè)、西寧網(wǎng)站制作、西寧網(wǎng)頁(yè)制作以及西寧網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,西寧網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到西寧省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

Imports System.Windows.Forms

在控制臺(tái)的Module中聲明一個(gè)計(jì)時(shí)器:

Private WithEvents Timer1 As New Timer()

把計(jì)時(shí)器的Tick事件靜態(tài)綁定到處理函數(shù)中:

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

'一些代碼

End Sub

在需要開(kāi)始計(jì)時(shí)的地方,修改其Interval、Enabled屬性:

Timer1.Interval = 1000

Timer1.Enabled = True

關(guān)于vb.net定時(shí)器問(wèn)題

Timer1.Interval = 500

Private Sub Timer1_Timer()

Timer1.Enabled = False

Dim ss As String

ss = Format(Now, "HH:mm:ss")

If ss = "12:00:00" Then

'執(zhí)行備份語(yǔ)句

End If

Timer1.Enabled = True

End Sub

還有一個(gè)辦法就是可以用SQL自身的功能,在SQL里面可以添加任務(wù) ,設(shè)置周期為每天,時(shí)間為12點(diǎn),到時(shí)候執(zhí)行一下備份

VB.NET 2005編寫定時(shí)關(guān)機(jī)程序

最近在網(wǎng)上搜索了一些關(guān)于實(shí)現(xiàn)關(guān)機(jī) 重啟 注銷的文章 發(fā)現(xiàn)大多介紹的是VB NET 用API實(shí)現(xiàn)這些功能 且在XPsp 環(huán)境下無(wú)法正常的關(guān)機(jī)與注銷 而對(duì)于VB NET 的介紹幾乎沒(méi)有 本文章所涉及的知識(shí)點(diǎn)有

用實(shí)現(xiàn)關(guān)機(jī) 重啟 注銷功能 通過(guò)使用textbox與timer控件的結(jié)合編寫定時(shí)器功能 為你的程序加上超鏈接

本篇文章具有一定的基礎(chǔ)性和廣泛的實(shí)用性 相信能夠給 初學(xué)者帶來(lái)一定的幫助

本文所使用的編程環(huán)境是Microsoft Visual Studio 首先打開(kāi) Visual Studio 在文件 (File) 菜單上 單擊新建項(xiàng)目 (New Project) 在新建項(xiàng)目 (New Project) 對(duì)話框的模板 (Templates) 窗格中 單擊 Windows 應(yīng)用程序 (Windows Application) 單擊確定 (OK)

具體步驟如下

首先在Form 窗體上添加一個(gè)Label 控件屬性text設(shè)置為:今天: 然后分別添加 個(gè)button控件name分別為button button button 它們的text屬性分別為 關(guān)閉計(jì)算機(jī)(啟動(dòng)定時(shí)器) 注銷 重新啟動(dòng)

現(xiàn)在我們就需要為程序加上一個(gè)定時(shí)器了 這個(gè)定時(shí)器需要與textbox 控件相關(guān)聯(lián) 輸入正確時(shí)間格式后就可以啟動(dòng)定時(shí)功能了 然后我們需要在窗體上添加一個(gè)timer 一個(gè)textbox 控件 和一個(gè)RadioButton 控件 讓它們保留默認(rèn)值不變 其中 TextBox 控件的text屬性設(shè)置為 : : RadioButton 控件text設(shè)置為 指定時(shí)間關(guān)機(jī)|時(shí)間格式 小時(shí): 分鐘: 秒如圖 所示

以上界面工作基本完成現(xiàn)在需要輸入代碼了

雙擊窗體進(jìn)入常規(guī) 聲明Public Class Form 事件中

CODE

Imports System Runtime InteropServicesImports Microsoft VisualBasicPublic Class Form _ 調(diào)用系統(tǒng)參數(shù)Friend Shared Function GetCurrentProcess() As IntPtrEnd Function

_Friend Shared Function OpenProcessToken(ByVal h As IntPtr

ByVal acc As Integer ByRef phtok As IntPtr) As BooleanEnd Function

_Friend Shared Function LookupPrivilegeValue(ByVal host As String

ByVal name As String ByRef pluid As Long) As BooleanEnd Function

_Friend Shared Function AdjustTokenPrivileges(ByVal htok As IntPtr

ByVal disall As Boolean ByRef newst As TokPriv Luid

ByVal len As Integer ByVal prev As IntPtr

ByVal relen As IntPtr) As BooleanEnd Function

_Friend Shared Function ExitWindowsEx(ByVal flg As Integer

ByVal rea As Integer) As BooleanEnd Function

Friend Const SE_PRIVILEGE_ENABLED As Integer = H Friend Const TOKEN_QUERY As Integer = H Friend Const TOKEN_ADJUST_PRIVILEGES As Integer = H Friend Const SE_SHUTDOWN_NAME As String = SeShutdownPrivilege Friend Const EWX_LOGOFF As Integer = H 注銷計(jì)算機(jī)Friend Const EWX_SHUTDOWN As Integer = H 關(guān)閉計(jì)算機(jī)Friend Const EWX_REBOOT As Integer = H 重新啟動(dòng)計(jì)算機(jī)Friend Const EWX_FORCE As Integer = H 關(guān)閉所有進(jìn)程 注銷計(jì)算機(jī)Friend Const EWX_POWEROFF As Integer = H Friend Const EWX_FORCEIFHUNG As Integer = H

_  引用參數(shù) Friend Structure TokPriv Luid Public Count As Integer Public Luid As Long Public Attr As IntegerEnd Structure

Private Shared Sub DoExitWin(ByVal flg As Integer) Dim xc As Boolean 判斷語(yǔ)句 Dim tp As TokPriv Luid Dim hproc As IntPtr = GetCurrentProcess()  調(diào)用進(jìn)程值 Dim htok As IntPtr = IntPtr Zero xc = OpenProcessToken(hproc TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY htok) tp Count =  tp Luid =  tp Attr = SE_PRIVILEGE_ENABLED xc = LookupPrivilegeValue(Nothing SE_SHUTDOWN_NAME tp Luid) xc = AdjustTokenPrivileges(htok False tp IntPtr Zero IntPtr Zero) xc = ExitWindowsEx(flg )End Sub

Public Shared Sub Reboot() DoExitWin((EWX_FORCE Or EWX_REBOOT)) 重新啟動(dòng)計(jì)算機(jī)End Sub

Public Shared Sub PowerOff() DoExitWin((EWX_FORCE Or EWX_POWEROFF)) 關(guān)閉計(jì)算機(jī)End Sub

Public Shared Sub LogoOff() DoExitWin((EWX_FORCE Or EWX_LOGOFF)) 注銷計(jì)算機(jī)End Sub

Dim entTime As Object 保存輸入時(shí)間Dim xianzaiTime As Object 保存實(shí)時(shí)時(shí)間Dim startTime As Object 保存開(kāi)始定時(shí)時(shí)間

注銷button 按鈕輸入code

Private Sub Button _Click(ByVal sender As System Object

ByVal e As System EventArgs) Handles Button ClickLogoOff() 注銷計(jì)算機(jī)End Sub

雙擊重新啟動(dòng)按鈕button 輸入code

Private Sub Button _Click(ByVal sender As System Object

ByVal e As System EventArgs) Handles Button Click

Reboot()

End Sub

雙擊關(guān)閉計(jì)算機(jī)按鈕button 輸入code

Private Sub Button _Click(ByVal sender As System Object

ByVal e As System EventArgs) Handles Button Click startTime = TimeOfDay If Not IsDate(TextBox Text) Then 用IsData函數(shù)判斷輸入的時(shí)間格式MsgBox( 你所輸入的不是時(shí)間格式 ! 錯(cuò)誤 ) ElseentTime = TimeValue(TextBox Text) End If Timer Enabled = True  啟動(dòng)定時(shí)器 Me WindowState = System Windows Forms FormWindowState Minimized  最小化窗體

End Sub

如圖

雙擊timer 控件如圖

輸入代碼

Private Sub Timer _Tick(ByVal sender As System Object

ByVal e As System EventArgs) Handles Timer Tick xianzaiTime = TimeOfDay If RadioButton Checked Then

If DateDiff(Microsoft VisualBasic DateInterval Second

xianzaiTime entTime) Then 用DateDiff函數(shù)判斷是否到時(shí)間了

End IfEnd If

PowerOff() 關(guān)閉計(jì)算機(jī)End Sub

好了 基本上一個(gè)定時(shí)關(guān)機(jī)程序就完成了 接下來(lái)加一個(gè)超級(jí)鏈接吧!當(dāng)然對(duì)于高手來(lái)說(shuō)可能是廢話 但是對(duì)于新手來(lái)說(shuō)這也是必備的 這個(gè)超級(jí)鏈接當(dāng)然是我們最喜歡的天極網(wǎng)開(kāi)發(fā)頻道了

先創(chuàng)建一個(gè)Label控件吧 把它托到窗體上 將text屬性設(shè)置為天極網(wǎng)開(kāi)發(fā)頻道如圖

接下來(lái)需要輸入代碼了 雙擊窗體Form

進(jìn)入Public Class Form 事件

代碼

Private Declare Function ShellExecute Lib shell dll

Alias ShellExecuteA (ByVal hwngnd As Integer

ByVal lpOperation As String ByVal lpFile As String

ByVal lpParameters As String ByVal lpDirectory As String

ByVal nShowCmd As Integer) As Integer

如圖

雙擊剛才添加的label屬性text:(天極網(wǎng)開(kāi)發(fā)頻道)中輸入以下代碼

Private Sub Label _Click(ByVal sender As System Object

ByVal e As System EventArgs) Handles Label ClickShellExecute( open CStr( ) CStr( ) )

End SubEnd Class

OK!全部搞定 按F 鍵運(yùn)行如圖 所示 選擇相應(yīng)選項(xiàng)后點(diǎn)擊(關(guān)閉計(jì)算機(jī)啟動(dòng)定時(shí)器按鈕)就可以了 現(xiàn)在程序?qū)凑漳闼O(shè)定的時(shí)間而啟動(dòng)關(guān)閉計(jì)算機(jī)選項(xiàng)

lishixinzhi/Article/program/net/201311/12366

怎么利用vb.net中的定時(shí)器使轉(zhuǎn)盤轉(zhuǎn)起來(lái)?

你沒(méi)有明白Timer控件的工作原理:

你可以按照下面代碼,做一個(gè)實(shí)驗(yàn),然后體會(huì),關(guān)鍵:

Timer控件按照其Interval設(shè)置的值,每間隔一定的時(shí)間,自動(dòng)觸發(fā)其Tick事件。

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Label1.Text = Now

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Timer1.Interval = 1000

Timer1.Enabled = True

End Sub

End Class

VB.NET 計(jì)時(shí)器的問(wèn)題

不對(duì)。步驟如下:

添加一個(gè)label標(biāo)簽名字label1 用來(lái)顯示時(shí)間

再添加一個(gè)timer控件 名字timer1 interval屬性=1000 用來(lái)計(jì)時(shí)

窗體添加代碼

Dim t As Date '用來(lái)記錄時(shí)間

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _

System.EventArgs) Handles Timer1.Tick

t = t.AddSeconds(1)

Label1.Text = "登錄時(shí)間:" t.TimeOfDay.ToString

End Sub


當(dāng)前文章:包含vb.net內(nèi)部定時(shí)器的詞條
本文地址:http://weahome.cn/article/hggopp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部