Tutorial : How create a simple Game with VBA Excel

in #science7 years ago

Hi ladies and gentleman, meet me again.

Now I want to show you about tutorial how make a simple Spin Machine Game or Slot Machine Game with VBA Excel.
I hope this can help you for expanding nice game with VBA Excel.
IMG_20180304_084656.jpg
Ok, we now to begin to create it

  1. Create 3 button with Developer and change name to PLAY, RESET and BANK.
    IMG_20180304_085115.jpg
  2. Make cells with following format, and input 0 to cells F1, J2 and B15
  3. Marge cells B4:D11, F4:H11 and J4:L11
    Screenshot_2018-03-04-08-54-45-426.jpeg
  4. Increase font size on cells B4, F4 and J4 to 100 poin, Change font to type with you want, I choose ALGERIAN and Red font color
  5. Change Conditional formating to Color Scales with you want, I choose Red - Yellow Green color scales.
    Screenshot_2018-03-04-08-55-18-840.jpeg
  6. Change Conditional formating to Icon Sets with you want, I choose to 3 Signs.
    Screenshot_2018-03-04-08-56-48-051.jpeg

Screenshot_2018-03-04-08-57-07-611.jpeg

Screenshot_2018-03-04-08-58-14-849.jpeg

  1. Press Alt+F11 and then insert a modules
    Screenshot_2018-03-04-09-20-05-001.jpeg
  2. Enter the following VBA code to make the Spin Machine :

Sub PLAY_Click()
Range("B4") = Int((7 * Rnd) + 1)
Range("F4") = Int((7 * Rnd) + 1)
Range("J4") = Int((7 * Rnd) + 1)
Range("J2").Value = Range("F1")
x = x + 1
Range("F1").Value = Range("F1").Value + x
y = Range("B4") & Range("F4") & Range("J4")

If y = "111" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.111"
End If
If y = "222" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.222"
End If
If y = "333" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.333"
End If
If y = "444" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.444"
End If
If y = "555" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.555"
End If
If y = "666" Then
Range("F1").Value = Range("F1") + y
MsgBox "BONUS Rp.666"
End If
If y = "777" Then
Range("F1").Value = 1000000 + y
MsgBox "LUCKY SEVEN ! YOU WINNER !!!" & vbNewLine & "YOUR WIN MONEY : Rp. 1.000.000"
End If
End Sub
Sub BANK()
Range("B15").Value = Range("B15") + Range("F1")
MsgBox "SAVE YOUR MONEY TO BANK, SUCCESS !"
x = 0
Range("F1").Value = x
Range("B4").Value = 0
Range("F4").Value = 0
Range("J2").Value = 0
Range("J4").Value = 0
End Sub
Sub start()
x = 0
Range("F1").Value = x
Range("B4").Value = 0
Range("F4").Value = 0
Range("J2").Value = 0
Range("J4").Value = 0
Range("B15").Value = 0
End Sub

  1. Function button :
  • Button SPIN to randomise slot machine
  • Button RESET for Start to Beginning Game
  • SAVE to Saving your money
  1. Enjoy play game :)
    Screenshot_2018-03-04-08-59-24-059.jpeg
    Screenshot_2018-03-04-08-58-36-886.jpeg
    Screenshot_2018-03-04-08-59-46-781.jpeg

So tutorial by me, don't forget your vote for me hopefully can be developed to be better and see you again :)

Sort:  

Congratulations @khaidir22! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @khaidir22! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.15
TRX 0.16
JST 0.028
BTC 68160.40
ETH 2442.97
USDT 1.00
SBD 2.37