回答編集履歴

1

戻り値を使う処理に変更

2018/06/08 08:49

投稿

Wind
Wind

スコア442

test CHANGED
@@ -7,6 +7,10 @@
7
7
 
8
8
 
9
9
  ```C#
10
+
11
+ private bool bolPoint = false; // 小数点フラグ
12
+
13
+
10
14
 
11
15
  /// <summary>
12
16
 
@@ -24,17 +28,17 @@
24
28
 
25
29
 
26
30
 
27
-
28
-
29
31
  //小数処理
30
32
 
33
+ bool flag;
34
+
31
- InputControl(textHeight, e);
35
+ flag = InputControl(textHeight, e);
36
+
37
+ if (flag) { // 戻り値を使った処理
38
+
39
+ }
32
40
 
33
41
  }
34
-
35
-
36
-
37
- private bool bolPoint = false; // 小数点フラグ
38
42
 
39
43
 
40
44
 
@@ -44,9 +48,13 @@
44
48
 
45
49
  /// </summary>
46
50
 
47
- private void InputControl(TextBox txt, KeyPressEventArgs e)
51
+ private bool InputControl(TextBox txt, KeyPressEventArgs e)
48
52
 
49
53
  {
54
+
55
+ if (bolPoint == false) return false; // 小数点が無ければ抜ける
56
+
57
+
50
58
 
51
59
  //小数点以下一桁のみ入力可能
52
60
 
@@ -61,10 +69,6 @@
61
69
  string possible = txt.Text;
62
70
 
63
71
  string[] conversion = possible.Split('.'); //ここで(.)で整数と少数を分ける。
64
-
65
-
66
-
67
- if (bolPoint == false) return; // 小数点が無ければ抜ける
68
72
 
69
73
 
70
74
 
@@ -97,6 +101,8 @@
97
101
  }
98
102
 
99
103
  }
104
+
105
+ return true;
100
106
 
101
107
  }
102
108