Excelのこととか色々

マクロをどんな Excel ファイルにも実行できるように設定して、3秒かかる操作も1秒で完了。あといろいろ書いてみます・・・

【Excel/VBA】Janken game 01

 

    Janken icon

  

 

  _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

※Please correct my English if you find any mistakes. Thank you.

 

Save as "xlsm" with any name.

Goal

Janken Game

 

Prepare images of Rock, Paper, and Scissors

You can just show the text Rock, Paper, and Scissors, but It is boring, I think.

You can draw them, take photos, or copy them from websites and save them as "bmp", or "jpg".

 

* In Japanese law, we can use pictures or drawings just for ourselves as long as they are not in public.
   Please obey your country's laws for copyright issues.

  

Open VBE

[Developer] tab > [Visual Basic] 

Check this article for more detail.

 

www.tuna-kichi.com

 

Create form

Might be Saying "Creating the screen of the game" is more understandable for beginners.

 

Go [Insert] > [Userform] and the new user form will be added and appear with the toolbox.

    Add userform

You might lose it if your monitor is big or using multiple monitors but the toolbox appears somewhere for sure.

    

Let's make the game appearance referring to the draft drawing.

 

Create the parts 

Labels

Add the labels on the form.

Those are labels in red frames. 

    Label parts

 

Those properties are below.

    Properties for labels

 

Change favorable font type, font size, and font color.

 

Option buttons

Add three option buttons.

    Option buttons

 

Properties for option buttons

    Option buttons' properties

 

Images1

Add images for showing pictures you and the computer selected.

    Images

 

    Image control

 

Properties for the images.

    Properties for images

 

Images2

    Image2

 

They are also images but the setting is a bit different.

Set the size smaller and you have to have the pics of Rock, Paper, and Scissors on your PC.

 

Click the image and go to the [Piture] property.

Explore will appear when you click the three dots button for selecting bitmap picture.

    Set picture on the image control

 

Properties for images.

The difference from the other images is these three images are not visible as a default.

These images will appear on imgYou or imgComp when you play the game.

    Properties for images2

 

Command buttons

Add three command buttons.

    Add command buttons

 

    Command button control

 

Properties for command buttons.

    Properties for command buttons

 

I will write a macro for next time. 

 

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

 

 

PVアクセスランキング にほんブログ村 Excelのこととか色々 - にほんブログ村 にほんブログ村 子育てブログ 幼稚園児育児へ にほんブログ村 英語ブログ 初心者英語へ にほんブログ村 IT技術ブログ VBAへ