<% 'Progress Bar Webclass 'Copyright (c) 2003 - Jonathan Cook / G E K E . N E T 'This code may not be redistributed without permission, but may be used in your own projects 'without any recourse to the author, provided that this notice is maintained. Response.Buffer = True 'response buffering is required for progress bars to work Class ProgBar Private v_sBarColor 'Hex value Private v_sBorderColor 'Hex value Private v_sBackColor 'Hex value Private v_sBarName 'Bar name / ID Private v_sCaption 'String to show below progress bar Private v_iPixelPerc 'Number of pixels per percent Private v_iBarFullWidth 'Bar width Private v_iBarHeight 'Bar height Private v_iBarMargin 'Bar margin Private v_iFontSize 'Font size Private v_iBarPerc Private v_iBarWidth Private v_iFillNumber Private v_iFillAmount Private v_iLastPerc Private v_iPercBlock Public Property Let Width(iW) v_iBarFullWidth = iW v_iPixelPerc = Fix(iW / 100) End Property Public Property Get Width() Width = v_iBarFullWidth End Property Public Property Let Height(iH) v_iBarHeight = iH End Property Public Property Get Height() Height = v_iBarHeight End Property Public Property Let Margin(iM) v_iBarMargin = iM End Property Public Property Get Margin() Margin = v_iBarMargin End Property Public Property Let Name(sName) v_sBarName = sName End Property Public Property Get Name() Name = v_sBarName End Property Public Property Let Caption(sC) v_sCaption = sC End Property Public Property Get Caption() Caption = v_sCaption End Property Public Property Let Color(sC) If IsNumeric(sC) And Left(sC, 1) <> "#" Then v_sBarColor = "#" & sC Else v_sBarColor = sC End If End Property Public Property Get Color() Color = v_sBarColor End Property Public Property Let BorderColor(sC) If IsNumeric(sC) And Left(sC, 1) <> "#" Then v_sBorderColor = "#" & sC Else v_sBorderColor = sC End If End Property Public Property Get BorderColor() BorderColor = v_sBorderColor End Property Public Property Let BackColor(sC) If IsNumeric(sC) And Left(sC, 1) <> "#" Then v_sBackColor = "#" & sC Else v_sBackColor = sC End If End Property Public Property Get BackColor() BackColor = v_sBackColor End Property Public Property Let Percent(iP) If iP > 100 Then v_iBarPerc = 100 Else v_iBarPerc = iP End If v_iBarWidth = Round(v_iBarPerc * v_iPixelPerc, 0) If v_iBarPerc >= v_iLastPerc + v_iPercBlock Then v_ShowFill() End Property Public Property Get Percent() Percent = v_iBarPerc End Property Public Property Get FillWidth() FillWidth = v_iBarWidth End Property Public Property Let Full(iFl) v_iFillNumber = iFl End Property Public Property Get Full() Full = v_iFillNumber End Property Public Property Let Block(iP) v_iPercBlock = iP End Property Public Property Get Block() Block = v_iPercBlock End Property Private Sub Class_Initialize() v_sBarColor = "#6688FF" v_sBorderColor = "#000000" v_sBackColor = "#FFFFFF" v_iPixelPerc = 4 v_iBarFullWidth = 400 v_iBarWidth = 0 v_iFillAmount = 0 v_iFillNumber = 100 v_iPercBlock = 5 v_iBarHeight = 16 v_iFontSize = 12 v_iBarMargin = 2 v_sBarName = "progbar" v_sCaption = "" End Sub Public Function Bar(sName, iW, iH, iM, iFl, iP, sColor, sBkC, sBrC, sCap) v_iBarFullWidth = iW v_iBarHeight = iH v_iBarMargin = iM v_sBarName = sName v_sCaption = sCap v_iPercBlock = iP v_iFillNumber = iFl If IsNumeric(sColor) And Left(sColor, 1) <> "#" Then v_sBarColor = "#" & sColor Else v_sBarColor = sColor End If If IsNumeric(sBrC) And Left(sBrC, 1) <> "#" Then v_sBorderColor = "#" & sBrC Else v_sBorderColor = sBrC End If If IsNumeric(sBkC) And Left(sBkC, 1) <> "#" Then v_sBackColor = "#" & sBkC Else v_sBackColor = sBkC End If Bar = True End Function Public Function WriteBar Response.Write("
") & vbCrLf If Len(v_sCaption) > 0 Then Response.Write("

" & v_sCaption & "

") & vbCrlF Response.Flush WriteBar = True End Function Public Function WriteScript(bFirst) If bFirst Then Response.Write("") & vbCrLf Response.Flush End If WriteScript = True End Function Public Function WriteStyle Response.Write("") & vbCrLf Response.Flush WriteStyle = True End Function Private Function v_ShowFill() Response.Write("") & vbCrLf Response.Flush v_iLastPerc = v_iLastPerc + v_iPercBlock v_iFillAmount = 0 End Function Public Function Fill(iAdd) v_iFillAmount = v_iFillAmount + iAdd v_iBarPerc = v_iBarPerc + (iAdd * 100 / v_iFillNumber) v_iBarWidth = Round(v_iBarPerc, 0) * v_iPixelPerc If v_iBarWidth > v_iBarFullWidth Then v_iBarWidth = v_iBarWidth - v_iBarFullWidth If v_iBarPerc >= (v_iLastPerc + v_iPercBlock) Then v_ShowFill End Function Public Function Clear v_iBarPerc = 0 v_iLastPerc = 0 v_iBarWidth = 0 v_iFillAmount = 0 Response.Write("") & vbCrLf Response.Flush End Function End Class %>