-
https://cafe.naver.com/excelmaster/165990 에 올라온 질문입니다.
사다리나 명단 추첨을 하려는데 버튼을 누르자마자 명단이 짠 하고 나타나니
긴장감이 전혀 없습니다. 추첨은 쪼는 맛이 있어야하는데요.
그래서 슬롯머신 효과를 주어 이름이 나타나게 했습니다.
주로 방송에서 득표수같은 걸 나타낼 때 많이 쓰입니다.
Option ExplicitPrivate tmp() As StringPrivate v As VariantPrivate Sub CommandButton1_Click()Dim cnt1 As Integer, cnt2 As Integer, cnt3 As IntegerDim AbortTime As DateDim time1 As DateDim time2 As DateDim MyChamp As StringRandomizeMyChamp = v(Int(Rnd * UBound(v)), 1) '당첨자'지연할 시간AbortTime = Now + TimeValue("00:00:03")time1 = AbortTime + TimeValue("00:00:01")time2 = AbortTime + TimeValue("00:00:02")'이름 섞기Do Until Now > AbortTimeDoEventsLabel1.Caption = tmp(Int(Rnd * UBound(tmp)))Label2.Caption = tmp(Int(Rnd * UBound(tmp)))Label3.Caption = tmp(Int(Rnd * UBound(tmp)))LoopLabel3.Caption = Mid(MyChamp, 3, 1)Do Until Now > time1DoEventsLabel1.Caption = tmp(Int(Rnd * UBound(tmp)))Label2.Caption = tmp(Int(Rnd * UBound(tmp)))LoopLabel2.Caption = Mid(MyChamp, 2, 1)Do Until Now > time2DoEventsLabel1.Caption = tmp(Int(Rnd * UBound(tmp)))LoopLabel1.Caption = Mid(MyChamp, 1, 1)End SubPrivate Sub UserForm_Initialize()Dim i As IntegerDim miniI As IntegerDim j As IntegerCommandButton1.Enabled = False'이름을 분해하여 배열에 삽입v = Range("A1").CurrentRegionFor i = 1 To UBound(v, 1)For miniI = 1 To Len(v(i, 1))ReDim Preserve tmp(j)tmp(j) = Mid(v(i, 1), miniI, 1)j = j + 1NextNextCommandButton1.Enabled = TrueEnd Subcs 'VB(A)' 카테고리의 다른 글
유효성검사 유일값 가져오기 (0) 2021.01.19 미디어 파일을 날짜별로 분류 (6) 2019.12.25 여러 개의 텍스트박스를 클릭하여 이름 알아내기 (0) 2019.06.17 [정규식] 단어 들어 있는 문장찾기 (0) 2019.06.03 도형 이름을 활용하여 도형 클릭시 해당 셀로 이동하기 (0) 2019.04.01 댓글