單位不容許電腦安裝遊戲,但是不能不讓裝OFFICE吧,想了想,用VBA編程編一段代碼,玩玩小遊戲,打發一下快下班的時間吧!
最後實現了,代碼僅需 50行,可移植。
快來演示一下吧:
看看代碼:
代碼:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i, j, n, m As Integer
Dim vd, Hd As Integer
Dim sum As Integer
Dim arr(1 To 5, 1 To 5)
Dim bc, br As Integer
‘》》》》》》》》
bc = ActiveCell.Column
br = ActiveCell.Row
If bc < 6 And br < 6 Then
If Cells(br, bc) <> "*" Then
ActiveCell.Interior.Color = 255
sum = sum 1
Cells(br 20, bc) = 1
If Cells(26, 6) > 18 Then
For i = 1 To 5
For j = 1 To 5
Cells(i, j).Interior.Color = 255
Next
Next
MsgBox "恭喜你!你赢了!"
End If
Else
For i = 1 To 5
For j = 1 To 5
Cells(i, j).Interior.Color = 255
Next
Next
MsgBox "你輸了!"
End If
End If
End Sub
有需要的關注我----私信
,