[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『Do Loopを使って作りたいです。』(初心者です)
InputBoxからMsgBoxにして、はい、いいえ、キャンセルの三つのボタンを出して、マウスだけで操作できるようにしたいです。
勝敗数をタイトルバーに出現させたいです。
〇●△での履歴を出したいです。rirekiがわからないので教えてほしいです。
できれば自分の形に合わせて教えてもらえると、とても助かります。
お願いします。
Sub ex5b()
Dim com As Integer, man As Integer Const gu As Integer = 0, choki As Integer = 1, pa As Integer = 2 Const msg As String = "あなたの手は?(0,1,2)" Dim kekka As String Dim comHand As String, manHand As String Dim atai As Integer
Randomize
Do com = Int(Rnd * 3) man = InputBox(msg, "じゃんけん")
atai = (com - man + 3) Mod 3 If atai = 0 Then kekka = "あいこ" If atai = 1 Then kekka = "あなたの勝ち" If atai = 2 Then kekka = "パソコンの勝ち"
MsgBox "You=" & man & ", PC=" & com & " > " & kekka
rireki = rireki & "〇" & "●" & "△" Loop End Sub
< 使用 Excel:unknown、使用 OS:unknown >
https://docs.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/msgbox-function
(ひまつぶし) 2022/01/03(月) 12:01
学校の課題なんですかね? >できれば自分の形に合わせて教えてもらえると と言われるとかえってどっか変えてようとか...
Sub sample() Dim jan, kekka, kekkastr, rireki Randomize jan = Array("グー", "チョキ", "パー") kekkastr = Array("引き分け", "あなたの勝ち", "あなたの負け") rireki = Array("引き分け", 0, "あなたの勝ち", 0, "あなたの負け", 0) Do man = InputBox("グー:0 チョキ:1 パー:2 おわる:0〜1以外") If man < 0 Or 2 < man Then Exit Do kekka = Int(Rnd() * 3) MsgBox "あなた: " & jan(man) & vbLf & _ "PC : " & jan((man + kekka) Mod 3) & vbLf & _ kekkastr(kekka) rireki(kekka * 2 + 1) = rireki(kekka * 2 + 1) + 1 Application.Caption = Join(rireki) Loop MsgBox Join(rireki) Application.Caption = "" End Sub (´・ω・`) 2022/01/03(月) 13:10
mid("△○●", atai + 1, 1)
こんなの?
(きまぐれおじさん) 2022/01/03(月) 17:07
Sub 整理() Dim com As Integer, man As Integer Dim kekka As String, atai As Integer Dim rireki As String
Stop 'ブレークポイントの代わり
rireki = "履歴:" Do com = Int(Rnd * 3) man = InputBox("あなたの手は?(0:グー,1:チョキ,2:パー)", "じゃんけん") atai = (com - man + 3) Mod 3
If atai = 0 Then kekka = "あいこ" If atai = 1 Then kekka = "あなたの勝ち" If atai = 2 Then kekka = "パソコンの勝ち" rireki = rireki & Array("相", "勝", "負")(atai)
If MsgBox(Prompt:="You=" & man & ", PC=" & com & " > " & kekka & vbLf & "つつける?", Buttons:=vbYesNo, Title:=rireki) = vbNo Then Exit Do Loop End Sub
(もこな2 ) 2022/01/04(火) 01:42
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.