怎样在进度条中显示(0%-100%)的字样?

解决方案 »

  1.   

    用ProgressBar1控件啊,把最大设成100,最小设成0,算百分比为值
      

  2.   

    haipingma(ToJava)  你有,发一个上来看看
      

  3.   

    在ProgressBar1控件上(正中)加一个lable标签,并设置为透明,把当前ProgressBar1的值换算成百分数,赋予lable即可。
      

  4.   

    Option ExplicitPrivate Sub Form_Load()
        Timer1.Interval = 100
        Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
        With ProgressBar1
            If .Value = .Max Then
                Timer1.Enabled = False
                Exit Sub
            End If
            
            .Value = .Value + 1
            Label1.Caption = Format(.Value * 100 / .Max, "##") & "%"
        End With
    End Sub
      

  5.   

    自画代码如下:'缺省属性值:
    Const m_def_ShowLabel = True
    Const m_def_Max = 100
    Const m_def_Min = 0
    Const m_def_Value = 0
    '属性变量:
    Dim m_Font As Font
    Dim m_ShowLabel As Boolean
    Dim m_Max As Long
    Dim m_Min As Long
    Dim m_Value As Long
    '事件声明:
    Event Click()
    Event DblClick()
    Event KeyDown(KeyCode As Integer, Shift As Integer)
    Event KeyPress(KeyAscii As Integer)
    Event KeyUp(KeyCode As Integer, Shift As Integer)
    Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)'注意!不要删除或修改下列被注释的行!
    'MappingInfo=Picture2,Picture2,-1,BackColor
    Public Property Get BackColor() As OLE_COLOR
        BackColor = Picture2.BackColor
    End PropertyPublic Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
        Picture2.BackColor() = New_BackColor
        PropertyChanged "BackColor"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=8,0,0,100
    Public Property Get Max() As Long
        Max = m_Max
    End PropertyPublic Property Let Max(ByVal New_Max As Long)
        m_Max = New_Max
        PropertyChanged "Max"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=8,0,0,0
    Public Property Get Min() As Long
        Min = m_Min
    End PropertyPublic Property Let Min(ByVal New_Min As Long)
        m_Min = New_Min
        PropertyChanged "Min"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=8,0,0,0
    Public Property Get Value() As Long
        Value = m_Value
    End PropertyPublic Property Let Value(ByVal New_Value As Long)
        If New_Value >= m_Max Then
            New_Value = m_Max
        End If
        Dim charLength As Integer
        Dim PrintString As String    m_Value = New_Value
        PropertyChanged "Value"
                
            Picture2.Width = (m_Value) / m_Max * Picture1.Width
            
            PrintString = CStr(Int(m_Value * 100 / m_Max)) & "%"
            
            charLength = Len(PrintString)
            If charLength = 2 Then
                PrintString = "  " & PrintString
            ElseIf charLength = 3 Then
                PrintString = " " & PrintString
            End If
            Picture1.Cls
            Picture2.Cls
            
            
            Picture1.CurrentX = (Picture1.ScaleWidth - m_Font.Size * 3 * 20) / 2
            Picture1.CurrentY = (Picture1.ScaleHeight - m_Font.Size * 20) / 2
            Picture2.CurrentX = (Picture1.ScaleWidth - m_Font.Size * 3 * 20) / 2
            Picture2.CurrentY = (Picture1.ScaleHeight - m_Font.Size * 20) / 2
            Picture1.ForeColor = Picture2.BackColor
            Picture2.ForeColor = Picture1.BackColor
            If m_ShowLabel = True Then
                Picture1.Print PrintString
                Picture2.Print PrintString
            End If
            
    End PropertyPrivate Sub UserControl_Initialize()
        Picture2.Width = 0End Sub'为用户控件初始化属性
    Private Sub UserControl_InitProperties()
        m_Max = m_def_Max
        m_Min = m_def_Min
        m_Value = m_def_Value
        Set m_Font = Ambient.Font
        m_ShowLabel = m_def_ShowLabel
    End Sub'从存贮器中加载属性值
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)    Picture2.BackColor = PropBag.ReadProperty("BackColor", &H80000001)
        m_Max = PropBag.ReadProperty("Max", m_def_Max)
        m_Min = PropBag.ReadProperty("Min", m_def_Min)
        m_Value = PropBag.ReadProperty("Value", m_def_Value)
        Set m_Font = PropBag.ReadProperty("Font", Ambient.Font)
        m_ShowLabel = PropBag.ReadProperty("ShowLabel", m_def_ShowLabel)
        Picture1.Appearance = PropBag.ReadProperty("Appearance", 1)
    End SubPrivate Sub UserControl_Resize()
    On Error Resume Next
    Picture1.Left = 0
    Picture1.Width = UserControl.ScaleWidth
    Picture1.Top = 0
    Picture1.Height = UserControl.ScaleHeightWith Picture2
    .Left = Picture1.ScaleLeft
    .Width = m_Value / m_Max * Picture1.ScaleWidth
    .Top = Picture1.ScaleTop
    .Height = Picture1.ScaleHeight
    End WithEnd Sub'将属性值写到存储器
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)    Call PropBag.WriteProperty("BackColor", Picture2.BackColor, &H80000001)
        Call PropBag.WriteProperty("Max", m_Max, m_def_Max)
        Call PropBag.WriteProperty("Min", m_Min, m_def_Min)
        Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
        Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)
        Call PropBag.WriteProperty("ShowLabel", m_ShowLabel, m_def_ShowLabel)
        Call PropBag.WriteProperty("Appearance", Picture1.Appearance, 1)
    End Sub
    '注意!不要删除或修改下列被注释的行!
    'MemberInfo=6,0,0,
    Public Property Get Font() As Font
        Set Font = m_Font
    End PropertyPublic Property Set Font(ByVal New_Font As Font)
        Set m_Font = New_Font
        PropertyChanged "Font"
    End Property'注意!不要删除或修改下列被注释的行!
    'MemberInfo=0,0,0,True
    Public Property Get ShowLabel() As Boolean
        ShowLabel = m_ShowLabel
    End PropertyPublic Property Let ShowLabel(ByVal New_ShowLabel As Boolean)
        m_ShowLabel = New_ShowLabel
        PropertyChanged "ShowLabel"
    End Property'注意!不要删除或修改下列被注释的行!
    'MappingInfo=Picture1,Picture1,-1,Appearance
    Public Property Get Appearance() As Integer
        Appearance = Picture1.Appearance
    End PropertyPublic Property Let Appearance(ByVal New_Appearance As Integer)
        Picture1.Appearance() = New_Appearance
        PropertyChanged "Appearance"
    End Property
      

  6.   

    自定义一个控件,很简单的,请看例程http://websx.home.zccn.net/bbs/SavePost.asp?Action=snew&boardid=95