1. UserForm을 하나와 Module을 하나 추가합니다.
2. 다음으로 Label을 3개(Label1, Label2, Label3) 추가합니다.(아래 사진에는 Label1개가 안나왔네요)
3. Label1 은 배경이 되는 BaceColor 색상을 정해줍니다.
4. Label2는 진행이 되는 BaceColor 색상을 정해줍니다.
※ Label3은 그냥 둡니다.
4. 다음으로 "UserForm1"의 이름을 "pBar"라고 이름을 바꿉니다.
5. "pBar"를 더블클릭하거나 소스보기를 해서 아래 소스를 붙여넣습니다.
Private min_Value As Long, run_Value As Long, max_Value As Long
Private Sub UserForm_Initialize()
min_Value = 0: run_Value = 0: max_Value = 100 '// 기본값 설정
Me.Height = 55: Me.Width = 300 '// 폼의 넓이와 높이를 지정
Label1.Caption = "": Label2.Caption = ""
With Label1: .Left = 5: .Top = 5: .Width = InsideWidth - 10: .Height = InsideHeight - 10: End With
'// 진행이 표시될 라벨의 사이즈와 위치 설정
With Label2: .Left = 5: .Top = 5: .Width = 0: .Height = InsideHeight - 10: End With
'// 진행값이 표시될 라벨의 사이즈와 위치, 백스타일 투명하게 설정
With Label3: .Left = 5: .Top = InsideHeight / 3: .Width = InsideWidth - 10: .Height = InsideHeight / 3: .BackStyle = 0: End With
Label2.Width = 0 '// 초기 진행상태 0
Label3 = "0 / " & max_Value '// 표시할 테스트 초기값
Public Property Get Value() As String
'// 현재 진행값을 설정 및 업데이트 프로시저 호출
Public Property Let Value(runVale As String)
run_Value = runVale '// 현재 진생값을 변경
workRun '// 실제 라벨의 사이즈를 재설정하기 위해 프로시저 호출
'// 진행상태 바 업데이트 및 디스플레이값 출력
Label2.Width = (Me.InsideWidth - (Label2.Left * 2)) * (run_Value / max_Value)
Label3 = run_Value & " / " & max_Value
Public Property Get maxValue() As String
Public Property Let maxValue(maxVale_ As String)
Public Property Let Text(text_ As String)
|
정상 동작 되는지 한번 확인해 보겠습니다.
"Module1"에 테스트를 위해 아래처럼 코딩을 했습니다.
숫자를 정하고 숫자로 표시하고자 할때
If Not pBar.Visible Then pBar.Show 0
If (i Mod 100) = 0 Then pBar.Text = i & "번째 작업을 진행중입니다...."
|
If Not pBar.Visible Then pBar.Show 0
If (i Mod 100) = 0 Then pBar.Text = i & "번째 작업을 진행중입니다...."
pBar.Value = i / 50000 * 100
|
아래는 동작하는 영상입니다.
댓글