网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> web编程 >> ASP教程 >> 文章正文
  A Horizontal Percentage Gauge Class            【字体:
A Horizontal Percentage Gauge Class
作者:佚名    文章来源:不详    点击数:    更新时间:2007-7-1    




<%

  Dim sl_gauge

  Set sl_gauge = new Slgauge

  sl_gauge.BgColor = "#FFFFFF"

  sl_gauge.FgColor = "#990000"

  sl_gauge.Width = 78

  sl_gauge.Height = 5

  sl_gauge.MinVal = 0

  sl_gauge.MaxVal = 100

  sl_gauge.CurVal = iTestScore  '87% in our example

%>

<!-- Display the gauge -->

<table cellpadding=0 cellspacing=2>

  <tr>

     <td>0</td>

     <td><% = sl_gauge.RenderHtml %></td>

     <td>100%</td>

</tr>

</table>



<%

' Handy class for displaying a horizontal percentage gauge.

%>

<%

class Slgauge

  ' Colors.

  public BgColor

  public FgColor



  ' Dimensions.

  public Width

  public Height



  ' Values.

  public MinVal

  public MaxVal

  public CurVal



  ' Render this into HTML as a table.

  function RenderHtml

      ' Normalize the properties.

      if MinVal > MaxVal then

          Dim temp_val

          temp_val = MinVal

          MinVal = MaxVal

          MaxVal = temp_val

      end if



      if CurVal < MinVal then

          CurVal = MinVal

      elseif CurVal > MaxVal then

          CurVal = MaxVal

      end if



      ' Figure out the percentage that the CurVal is

      ' within MinVal and MaxVal.

      Dim percentage_val

      percentage_val = (CurVal - MinVal) / (MaxVal - MinVal)



      ' Compute the first and second widths.

      Dim fg_width

      fg_width = Round(Width * percentage_val)

      Dim bg_width

      bg_width = Width - fg_width



      RenderHtml = "<table cellspacing=0 cellpadding=0 width=" & _

                   Width & " height=" & Height & ">" _

                   & "<tr>"

      if fg_width > 0 then

          RenderHtml = RenderHtml _

                      & "<td width=" & fg_width & " height=" & _

                      Height & " bgcolor=" & FgColor & _

                      "><img src=/demos/Images/" & _

                      "1_pix_trans.gif></td>"

      end if

      if bg_width > 0 then

          RenderHtml = RenderHtml _

                          & "<td width=" & bg_width & " height=" & _

                          Height & " bgcolor=" & BgColor & _

                          "><img src=/demos/Images/" & _

                          "1_pix_trans.gif></td>"

      end if

      RenderHtml = RenderHtml _

                      & "</tr>" _

                      & "</table>"

  end function

end class

%>







站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • DataGrid控件实用小技巧 (1…

  • DataGrid控件实用小技巧 (2…

  • DataGrid控件实用小技巧 (3…

  • DataGrid控件实用小技巧 (4…

  • ASP的Recordset对象方法

  • Asp Object 之:ServerVariab…

  • 在客戶端實現datagrid的選取

  • Asp Object 之:QueryString

  • Asp Object 之:Form

  • 在DataGrid里面根据日期的不…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David