回答編集履歴
4
推敲
test
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
txt2.Text= StrConv(txt2.Text, vbNarrow)
|
16
16
|
Input1 = txt1.Text
|
17
17
|
Input2 = txt2.Text
|
18
|
-
If Not (IsNumeric(Input1)
|
18
|
+
If Not (IsNumeric(Input1) And IsNumeric(Input2)) Then
|
19
19
|
MsgBox "数値を入力してください。"
|
20
20
|
ChkParam = False
|
21
21
|
End If
|
3
推敲
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
Private Function ChkParam()
|
13
13
|
ChkParam = True
|
14
14
|
txt1.Text= StrConv(txt1.Text, vbNarrow) '半角に置き換える
|
15
|
-
txt2.Text= StrConv(txt2.Text,
|
15
|
+
txt2.Text= StrConv(txt2.Text, vbNarrow)
|
16
16
|
Input1 = txt1.Text
|
17
17
|
Input2 = txt2.Text
|
18
18
|
If Not (IsNumeric(Input1) Or IsNumeric(Input2)) Then
|
2
推敲
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
条件式が正しくありません
|
3
3
|
```VBA
|
4
4
|
If Not IsNumeric(Input1) Or IsNumeric(Input2) Then ' NG)Input1が数値でないまたはInput2が数値
|
5
|
-
If Not (IsNumeric(Input1)
|
5
|
+
If Not (IsNumeric(Input1) And IsNumeric(Input2)) Then ' OK)[Input1が数値かつInput2が数値] ではない
|
6
6
|
```
|
7
7
|
> 2つのテキストボックスに入力された値が半角数値であるか確認したい
|
8
8
|
|
1
推敲
test
CHANGED
@@ -10,18 +10,15 @@
|
|
10
10
|
ですので、入力値を[StrConv()](https://docs.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/strconv-function)で自動的に半角に置き換えて処理するようにしてはどうでしょうか。
|
11
11
|
```VBA
|
12
12
|
Private Function ChkParam()
|
13
|
+
ChkParam = True
|
13
14
|
txt1.Text= StrConv(txt1.Text, vbNarrow) '半角に置き換える
|
14
15
|
txt2.Text= StrConv(txt2.Text, , vbNarrow)
|
15
16
|
Input1 = txt1.Text
|
16
17
|
Input2 = txt2.Text
|
17
|
-
|
18
18
|
If Not (IsNumeric(Input1) Or IsNumeric(Input2)) Then
|
19
19
|
MsgBox "数値を入力してください。"
|
20
20
|
ChkParam = False
|
21
21
|
End If
|
22
|
-
|
23
|
-
ChkParam = True
|
24
|
-
|
25
22
|
End Function
|
26
23
|
```
|
27
24
|
|