simplerotator2.vb

来自「asp.net技术内幕的书配源码」· VB 代码 · 共 36 行

VB
36
字号
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Collections

Namespace myControls

Public Class SimpleRotator2: Inherits Control

Public Items As New ArrayList()

Protected Overrides Sub AddParsedSubObject( obj As Object )
  If ( TypeOf Obj Is RotatorItem2 )
    Items.Add( Obj )
  End If
End Sub

Protected Overrides Sub Render(objTextWriter As HtmlTextWriter)
  Dim objRandom As New Random
  Dim intRanIndex As Integer
  Dim objSelectedItem As RotatorItem2
  If Items.Count > 0 Then
    intRanIndex = objRandom.Next( Items.Count )
    objSelectedItem = CType( Items( intRanIndex ), RotatorItem2 )
    objTextWriter.Write( objSelectedItem.Text )
  End If
End Sub

End Class

Public Class RotatorItem2 : Inherits Control
 Public Text As String
End Class

End Namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?