Last active
November 12, 2018 11:39
-
-
Save sezemiadmin/5ce1398d60dc7763c0410097e585ae6c to your computer and use it in GitHub Desktop.
非エンジニア向けプログラミング超入門 サンプルコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Age = InputBox("あなたの年齢を入力してください") | |
| If Age >= 20 Then '>= は ≧ のこと | |
| MsgBox "成人です!" | |
| else | |
| MsgBox "未成年です!" | |
| End If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H = InputBox("あなたの身長 (m) を入力してください。") 'H (Height) という変数を入力できるボックスを表示 | |
| W = InputBox("あなたの体重 (kg) を入力してください。") 'W (Weight) という変数を入力できるボックスを表示 | |
| BMI = W / H / H 'BMIの値を求める演算 体重 ÷ 身長 ÷ 身長 を書く | |
| MsgBox "あなたお肥満指数は、" & BMI & "です。" 'BMIの演算結果をメッセージに出力 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '身長と体重を入力 | |
| H = InputBox("あなたの身長 (cm) を入力してください。") | |
| W = InputBox("あなたの体重 (kg) を入力してください。") | |
| 'cm を m に変更 | |
| H = H / 100 | |
| 'BMI を計算 | |
| BMI = Round(W / H / H, 1) | |
| 'BMI を出力し、肥満かどうかを判定 | |
| If BMI >= 25 then | |
| MsgBox "あなたお肥満指数は、" & BMI & "です。肥満です!" '出だしをズラすと読みやすくなります | |
| else | |
| MsgBox "あなたお肥満指数は、" & BMI & "です。肥満ではありません!" | |
| End If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' 円を表すクラス | |
| Class Circle | |
| ' 半径のデータ | |
| Private Radius | |
| ' 半径を設定するメソッド | |
| Public Sub SetRadius(R) | |
| Radius = R | |
| End Sub | |
| ' 自分の面積を返すメソッド | |
| Public Function GetArea() | |
| GetArea = Radius * Radius * 3.1415 | |
| End Function | |
| End Class | |
| ' 円を表すクラスを使うプログラム | |
| Set C = New Circle | |
| R = InputBox("円の半径を入力してください。") | |
| C.SetRadius(R) | |
| Area = C.GetArea() | |
| MsgBox "円の面積は、" & Area & "です。" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H = InputBox("あなたの身長 (cm) を入力してください。") | |
| W = InputBox("あなたの体重 (kg) を入力してください。") | |
| If IsNumric(H) And IsNumeric(W) then | |
| BMi = W / H / H | |
| MsgBox "あなたの肥満指数は、" & BMI & "です。" | |
| Else | |
| MsgBox "身長と体重に、数値を入力してください!" | |
| End If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' 円の面積を求める関数 | |
| Function GetCircleArea(R) | |
| GetCircleArea = R * R * 3.1415 | |
| End Function | |
| ' 円の面積を求める関数を使うプログラム | |
| R = InputBox("円の半径を入力してください。") | |
| Area = GetCircleArea(R) | |
| MsgBox "円の面積は、" & Area & "です。" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Balance = 10000 | |
| Do While Balance > 0 | |
| Price = InputBox("買い物した金額を入力してください。") | |
| Balance = Balance - Price | |
| Loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '身長と体重を入力 | |
| H = InputBox("あなたの身長 (cm) を入力してください。") | |
| W = InputBox("あなたの体重 (kg) を入力してください。") | |
| 'cm を m に変更 | |
| H = H / 100 | |
| 'BMI を計算し、結果を表示 | |
| BMI = Round(W / H / H, 1) | |
| MsgBox "あなたお肥満指数は、" & BMI & "です。" | |
| 'SW (Standard Weight) を計算し、結果を表示 | |
| SW = Round(22 * H * H, 1) | |
| MsgBox "あなたお肥満指数は、" & SW & "です。" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H = InputBox("あなたの身長 (cm) を入力してください。") | |
| W = InputBox("あなたの体重 (kg) を入力してください。") | |
| BMI = W / (H / 100) / (H / 100) 'cm を m にする | |
| SW = 22 * (H / 100) * (H / 100) '22 × 身長 × 身長 | |
| BMI = Round(BMI, 1) '小数点を丸める処理とその結果を入れる変数 | |
| MsgBox "あなたお肥満指数は、" & BMI & "です。" & "あなたの標準体重は、" & SW & "です。" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H = H / 100 | |
| BMI = Round(W / H / H, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment