📄 digitalclock.ascx.vb
字号:
Public MustInherit Class DigitalClock
Inherits System.Web.UI.UserControl
Protected WithEvents WebTimer1 As TimerWeb.TimerWeb.WebTimer
Protected WithEvents mydiv As System.Web.UI.HtmlControls.HtmlTableCell
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
AddHandler WebTimer1.Elapsed, AddressOf WebTimer1_Elapsed
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private _Interval As Integer = 10000
Private _style As String = "short"
' Define the Interval property to set/get
' the inteval to elapse
Public Property Interval() As Integer
Get
Return _Interval
End Get
Set(ByVal Value As Integer)
_Interval = Value
End Set
End Property
Public Property ClockStyle() As String
Get
Return _style
End Get
Set(ByVal value As String)
_style = value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebTimer1.Interval = _Interval
' raise the event to display clock
WebTimer1_Elapsed(sender, e)
End Sub
Private Sub WebTimer1_Elapsed(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim i As Integer
Dim fname As String
Dim strTime As String
If LCase(_style) = "short" Then
strTime = DateTime.Now.ToShortTimeString()
Else
strTime = DateTime.Now.ToLongTimeString()
End If
mydiv.InnerHtml = ""
For i = 0 To strTime.Length - 1
Select Case strTime.Substring(i, 1)
Case ":"
fname = "colon"
Case " "
fname = "blank"
Case Else
fname = strTime.Substring(i, 1)
End Select
mydiv.InnerHtml = mydiv.InnerHtml + "<img src='./digitalclock/images/" + fname + ".gif' border='0'/>"
Next
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -