|
|
Option Explicit
Sub myHappy()
Dim strmsg As String
Randomize '乱数発生ルーチンを初期化します。
Dim i As Long
i = Int((5 * Rnd) + 1) '1 から 6 までの乱数を発生させます。
Select Case i
Case 1
strmsg = "大吉"
Case 2
strmsg = "小吉"
Case 3
strmsg = "吉"
Case 4
strmsg = "凶"
Case 5
strmsg = "大凶"
Case Else
strmsg = "・・・"
End Select
MsgBox strmsg, , "おみくじ"
End Sub
Sub CreToolBar()
On Error GoTo ErrHandler
Application.CommandBars.Add(Name:="ak1bar").Visible = True
On Error GoTo 0
With Application.CommandBars("ak1bar")
.Controls.Add _
Type:=msoControlButton, ID:=2950, Before:=1
With .Controls(1)
.OnAction = "myHappy"
.Style = msoButtonIconAndCaption
.Caption = "おみくじ"
.TooltipText = "今日の運勢"
End With
End With
Exit Sub
ErrHandler:
MsgBox "Bar Off de ReTry"
End Sub
Sub DelToolBar()
On Error Resume Next
Application.CommandBars("ak1bar").Delete
On Error GoTo 0
End Sub
|
|