VB 2005問題???

2006-11-04 6:26 am
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

txt_time.Text = CInt(txt_time.Text) + 1
If txt_time.Text >= 30 Then
Timer1.Enabled = False
MsgBox("HI")
Close()
End If
End Sub
上面個code顯示的time係1,2,3......30
點樣改可變成00:00顯示time
更新1:

但laod唔到ar http://img292.imageshack.us/img292/7030/1ag9.png 要點改才load ar

回答 (2)

2006-11-04 9:40 am
✔ 最佳答案
補充下, 若要用Format , 就要自己處理進位問題

sample here:

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Text = CInt(TextBox1.Text) + 1
Dim sec As Integer
Dim min As Integer
sec = CInt(TextBox1.Text) Mod 60 ' 取得秒數
min = CInt(TextBox1.Text) / 60 ' 取得分鐘
TextBox2.Text = Format(min * 100 + sec, "00:00") ' 轉換成 分:秒 格式
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = 0
End Sub
End Class
2006-11-04 7:35 am
你可以用format依個函式將佢格代化左佢
sample:
format(30,"00:00")
就可以出到你要既00:30,但依個方式只適用於純數字


收錄日期: 2021-04-18 21:03:25
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061103000051KK04286

檢視 Wayback Machine 備份