.net 定時器Timer用法(Timeofday)

來源:互聯網
上載者:User
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim sql As String
Dim dt As New DataTable
Time2 = "11:14:00" '設定定時的時間,24小時制 ,應該放在出事載入程式中
Timer1.Interval = 1000 '設定計時器每秒鐘運行一次 ,應該放在出事載入程式中

Timer1.Enabled = True '計時器開始運行 ,應該放在出事載入程式中

Time1 = TimeOfDay() '擷取目前時間
rownum.Text = Time1
If Time1 = Time2 Then
Dim age
If agetext.Text = "" Then
age = 0
Else
age = Val(agetext.Text)
End If
sql = "select * from student where sid='" & xuehaotext.Text & "'"
conn = connect_db()
rs = New SqlDataAdapter(sql, conn)
'conn.Close()
rs.Fill(dt) '填充表
DataGridView1.DataSource = dt '將表中的資料顯示到datagridView控制項中,綁定資料
DataGridView1.Columns(0).HeaderText = "學號" '設定列名
DataGridView1.Columns(1).HeaderText = "姓名"
DataGridView1.Columns(2).HeaderText = "年齡"
DataGridView1.Columns(3).HeaderText = "成績"
rownum.Text = Str(DataGridView1.RowCount) '擷取行數
xuehaotext.Text = DataGridView1.Rows(0).Cells(0).Value '擷取datagridview中的某個值
nametext.Text = DataGridView1.Rows(0).Cells(1).Value
If (DataGridView1.Rows(0).Cells(2).Value = 0) Then
agetext.Text = ""
Else
agetext.Text = Str(DataGridView1.Rows(0).Cells(2).Value)
End If
If (DataGridView1.Rows(0).Cells(3).Value = 0) Then
scoretext.Text = ""
Else
scoretext.Text = Str(DataGridView1.Rows(0).Cells(3).Value)
End If
End If
End Sub

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.