- このページの著者ZISIRUが練習用に書いたコードです。
- 他で公開、配布、販売、使用する場合は変数名等、一部でもいいので改変して公開してください。
- 上記に違反しない限り私はすべての権利を主張しません。ご自由にお使いください。
- 本コードの使用において、この文章の表記、著者名の表記は不要です。
- 本コードは「現状のまま」提供され、明示または黙示を問わず、商品性、特定目的への適合性、非侵害に対する保証を含むがこれらに限定されない、いかなる種類の保証もありません。いかなる場合も、著者または著作権保有者は、契約行為、不法行為、またはその他の行為にかかわらず、本コード、または本コードの使用もしくはその他の取り扱いから生じる、またはそれに関連するいかなる請求、損害、またはその他の責任についても責任を負わないものとします。
- The code on this page was written by the author, ZISIRU, for practice purposes.
- If you wish to publish, distribute, or sell the code elsewhere, please modify it, even if only in terms of variable names, before making it public.
- As long as the above is not violated, I do not claim any rights and you are free to use it.
- There is no need to include this statement or the author’s name when using this code.
- This code is provided “as is”, and no warranties of any kind are offered, including but not limited to warranties of merchantability, fitness for a particular purpose, or non-infringement, whether expressed or implied. In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities arising from or related to the use of this code, regardless of whether they are based on contract, tort, or other legal theory.
VBAクラスモジュール、オブジェクト名:消去_
内容は、rowとcolumnの二重ループで左上から無色の数をカウントしてそのrowの無色数が0、つまりブロックが埋まっていたらそのrowを消します。
消したrowより上のrowをコピーし、下にオフセットしてペーストします。
消したらカウントをインクリメントします。
最後に消した総数を返しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Option Explicit Private スコア元_ As Long Property Get スコア元() As Long スコア元 = スコア元_ End Property Sub 消す() Dim R As Long Dim C As Long Dim 無色数 As Long Dim 消した行 As Long 消した行 = 0 スコア元_ = 0 For R = 5 To 24 無色数 = 0 For C = 6 To 17 If GAME.Cells(R, C).Interior.ColorIndex = xlNone Then 無色数 = 無色数 + 1 End If Next C If 無色数 = 0 Then GAME.Range(GAME.Cells(R, 6), GAME.Cells(R, 17)).Clear GAME.Range(GAME.Cells(5, 6), GAME.Cells(R - 1, 17)).Cut GAME.Range(GAME.Cells(5, 6), GAME.Cells(R - 1, 17)).Offset(1, 0) 消した行 = 消した行 + 1 End If Next R スコア元_ = スコア元_ + 消した行 End Sub |
コメント