[ Excel_Tipe29 へ戻る ] [ カラー 表示ソースコード ]
[ 更新履歴 ] 2019/2/14 : β1.00 , 2019/3/24 : β 4.40 , 2019/4/4 : Ver 1.00
2019/4/19 : VBA版ニュース ( Excel 向けアドイン( PhoneNumberAddin.xla ) を用意しました )
2019/5/11 : 番号翻訳テーブルを [ 2019/5/7 版 ] に差替えました
2020/7/20 : 番号翻訳テーブルを [ 2020/6/1 版 ] に差替えました
2022/8/2 : 番号翻訳テーブルを [ 2022/7/1 版 ] に差替えました
以下に示す テスト ツール を実行すると下記のように表示されます。
こちら から 下記テストツールのファイルをダウンロードできます。
[ JavaScript ]
[ JAVA ]
[ PHP ]
[ Perl ]
[ Python ]
[ Ruby ]
[ VBA / VB6 ]
[ VB.net ]
[ この場所へのリンク ]
[ この場所へのリンク ]
---------- JavaScript 版 テストコード ----------
電話番号翻訳 テーブル を JSON ファイルから読込み ⇒ TelephoneCheck_withJSON.js ( JavaScript ベース バージョン )
〃 を ソースコード 内に収録 ⇒ TelephoneCheck.js ( JavaScript 派生 バージョン [ 移植版 の ベース ] )
( Coloring by SyntaxHighlighter )
<HEAD> <script src="JS/jquery-1.12.4.min.js" charset="UTF-8"></script> <script src="JS/TelephoneCheck_withJSON.js"></script> // JSON 利用版では jQuery が必要 または <script src="JS/TelephoneCheck.js"></script> <script language="JavaScript"> <!-- // TelphoneCheck.js テスト ツール // function ResetTest() { var target = document.getElementById("output"); target.innerHTML = ""; } function TelphoneCheckTest() { var TelCode = Form1.TextBox1.value; // <-- テスト 電話番号 var Result1 = InitTelephone("Type"); var Result2 = InitTelephone("Value"); var Result3 = InitTelephone("Value"); var Result4 = InitTelephone("Value"); Result1 = GetTypeTelephone(TelCode); // EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx Result2 = FormatTelephone(TelCode , 1); Result3 = ValidateTelephone(Result2.TelEdit); // 編集電話番号 Result4 = ValidateTelephone(TelCode); // 数字のみ電話番号 var ResultMsg = "<br> TelCode= [ " + TelCode + " ]" + "<br>-- GetTypeTelephone --" + "<br> TelType= " + Result1.TelType + "<br> SizeAll= " + Result1.SizeAll + "<br> Size1= " + Result1.Size1 + "<br> Size2= " + Result1.Size2 + "<br> Size3= " + Result1.Size3 + "<br> ErrId= " + Result1.ErrId + "<br><br>-- FormatTelephone --" + "<br> TelType= " + Result2.TelType + "<br> EditType= " + Result2.EditType + "<br> TelEdit= " + Result2.TelEdit + "<br> ErrId= " + Result2.ErrId + "<br><br>-- ValidateTelephone [1] -- ( " + Result2.TelEdit + " )" + "<br> TelType= " + Result3.TelType + "<br> EditType= " + Result3.EditType + "<br> TelEdit= " + Result3.TelEdit + "<br> ErrId= " + Result3.ErrId + "<br><br>-- ValidateTelephone [2] -- ( " + TelCode + " )" + "<br> TelType= " + Result4.TelType + "<br> EditType= " + Result4.EditType + "<br> TelEdit= " + Result4.TelEdit + "<br> ErrId= " + Result4.ErrId + "<br><br>"; var target = document.getElementById("output"); target.innerHTML = ResultMsg; } function PhoneNumberTest() { var TelCode = Form1.TextBox2.value; // <-- TelCode,Action if (TelCode === "") { Form1.TextBox3.value = ""; return; } var arg = TelCode.split(","); var Result = PhoneNumber(arg[0].trim(), arg[1].trim()); Form1.TextBox3.value = String(Boolean(Result)) + " [ " + String(Result) + " ]"; } --> </SCRIPT> </HEAD> <BODY> <FORM name="Form1"> <FONT face="MS 明朝" style="line-height : 1.5em;"> <b>---- TelephoneCheck.js のテストツール ----</b><br><br> 電話番号(半角) <INPUT size="30" type="text" name="TextBox2" style="ime-mode:disabled;"> [ 電話番号,F1〜F6 or 編集電話番号,V ]<br> <INPUT type="button" name="Button2" value="PhoneNumber のテスト" onclick="PhoneNumberTest();"> ⇒ <INPUT size="30" type="text" name="TextBox3"><br> <br> <INPUT size="20" type="text" name="TextBox1" style="ime-mode:disabled;"> <INPUT type="button" name="Button1" value="TelephoneCheck.js のテスト" onclick="TelphoneCheckTest();"><br> <INPUT type="reset" name="Button2" value="リセット" onclick="ResetTest();"> ( この下に結果が表示されます )
</FONT> </FORM> <div class="contents" id="output" style="margin-left : 20px; font-family : 'Courier New'; font-size : small"></div> </BODY>
[ この場所へのリンク ]
---------- JAVA 版 テストコード ----------
( Coloring by SyntaxHighlighter )
// [ package MyLib ]内に TelephoneCheck.java がある前提 // TelphoneCheck.java テスト ツール // import java.util.Scanner; import java.util.regex.Pattern; import static MyLib.TelephoneCheck.*; import MyLib.TelephoneCheck.TelephoneCheckValue; import MyLib.TelephoneCheck.TelephoneType; public class PhoneTest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String Ans; String Arg; String[] ArgList; String TelCode = ""; // テスト 電話番号 Pattern patternYN = Pattern.compile("^[YyNn]$"); // Y/N , y/n TelephoneType Result1 = new TelephoneType(); TelephoneCheckValue Result2 = new TelephoneCheckValue(); TelephoneCheckValue Result3 = new TelephoneCheckValue(); TelephoneCheckValue Result4 = new TelephoneCheckValue(); String Result5 = ""; System.out.print("Test of PhoneNumber? (Y/N) > "); Ans = scan.nextLine(); if (patternYN.matcher(Ans).matches() != true) { System.out.print("-- End of TelephoneCheck Test --\n\n"); scan.close(); System.exit(0); } if ( (Ans.toUpperCase()).equals("Y") ) { // コンソールで何も入力せずに即リターンしたら終了 while (true) { System.out.print("PhoneNumber [ TelCode , Action ] > "); Arg = scan.nextLine(); // 電話番号,Action をコンソール入力 if (Arg.equals("")) { System.out.print("-- End of TelephoneCheck Test --\n\n"); scan.close(); break; } ArgList = Arg.split(",", 0); if (ArgList.length != 2) { System.out.print("Please enter [ TelCode , Action ]\n"); } else { Result5 = PhoneNumber(ArgList[0].trim(), ArgList[1].trim()); if (Result5.equals("0") || Result5.equals("")) { System.out.print("False [ " + Result5 + " ]\n"); } else { System.out.print("True [ " + Result5 + " ]\n"); } } } } else { // コンソールで何も入力せずに即リターンしたら終了 while (true) { System.out.print("TelephoneCheck > "); TelCode = scan.nextLine(); // 電話番号をコンソール入力 if (TelCode.equals("")) { System.out.print("-- End of TelephoneCheck Test --\n\n"); scan.close(); break; } Result1 = GetTypeTelephone(TelCode); // EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx Result2 = FormatTelephone(TelCode , 1); Result3 = ValidateTelephone(Result2.TelEdit); // 編集電話番号 Result4 = ValidateTelephone(TelCode); // 数字のみ電話番号 System.out.print( "\n TelCode= [ " + TelCode + " ]" + "\n-- GetTypeTelephone --" + "\n TelType= " + Result1.TelType + "\n SizeAll= " + Result1.SizeAll + "\n Size1= " + Result1.Size1 + "\n Size2= " + Result1.Size2 + "\n Size3= " + Result1.Size3 + "\n ErrId= " + Result1.ErrId + "\n\n-- FormatTelephone --" + "\n TelType= " + Result2.TelType + "\n EditType= " + Result2.EditType + "\n TelEdit= " + Result2.TelEdit + "\n ErrId= " + Result2.ErrId + "\n\n-- ValidateTelephone [1] -- ( " + Result2.TelEdit + " )" + "\n TelType= " + Result3.TelType + "\n EditType= " + Result3.EditType + "\n TelEdit= " + Result3.TelEdit + "\n ErrId= " + Result3.ErrId + "\n\n-- ValidateTelephone [2] -- ( " + TelCode + " )" + "\n TelType= " + Result4.TelType + "\n EditType= " + Result4.EditType + "\n TelEdit= " + Result4.TelEdit + "\n ErrId= " + Result4.ErrId + "\n\n"); } } } }
[ この場所へのリンク ]
---------- PHP 版 テストコード ----------
( Coloring by SyntaxHighlighter )
<?php // TelphoneCheck.php テスト ツール // require("TelephoneCheck.php"); $Ans = ""; $Arg = ""; $ArgList = ["",""]; $TelCode = ""; // テスト 電話番号 $Result1 = InitTelephone("Type"); $Result2 = InitTelephone("Value"); $Result3 = InitTelephone("Value"); $Result4 = InitTelephone("Value"); $Result5 = ""; echo "Test of PhoneNumber? (Y/N) > "; $Ans = trim(fgets(STDIN)); if ((mb_strtoupper($Ans) != "Y") && (mb_strtoupper($Ans) != "N")) { echo "-- End of TelephoneCheck Test --\n\n"; exit; } if (mb_strtoupper($Ans) == "Y") { # コンソールで何も入力せずに即リターンしたら終了 while (TRUE) { echo "PhoneNumber [ TelCode , Action ] > "; $Arg = trim(fgets(STDIN)); # 電話番号,Action をコンソール入力 if ($Arg == "") { echo "-- End of TelephoneCheck Test --\n\n"; break; } $ArgList = explode(",", $Arg); if (count($ArgList) != 2) { echo "Please enter [ TelCode , Action ]\n"; } else { $Result5 = PhoneNumber(trim($ArgList[0]), trim($ArgList[1])); echo ( mb_strtoupper(var_export((bool)$Result5, true)) . " [ " . (string)$Result5 . " ]\n"); } } } else { // コンソールで何も入力せずに即リターンしたら終了 while (TRUE) { echo "TelephoneCheck > "; $TelCode = trim(fgets(STDIN)); // 電話番号をコンソール入力 if ($TelCode == "") { echo "-- End of TelephoneCheck Test --\n\n"; break; } $Result1 = GetTypeTelephone($TelCode); // EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx $Result2 = FormatTelephone($TelCode, 1); $Result3 = ValidateTelephone($Result2["TelEdit"]); // 編集電話番号 $Result4 = ValidateTelephone($TelCode); // 数字のみ電話番号 echo ("\n TelCode= [ " . $TelCode . " ]" . "\n-- GetTypeTelephone --" . "\n TelType= " . $Result1["TelType"] . "\n SizeAll= " . $Result1["SizeAll"] . "\n Size1= " . $Result1["Size1"] . "\n Size2= " . $Result1["Size2"] . "\n Size3= " . $Result1["Size3"] . "\n ErrId= " . $Result1["ErrId"] . "\n\n-- FormatTelephone --" . "\n TelType= " . $Result2["TelType"] . "\n EditType= " . $Result2["EditType"] . "\n TelEdit= " . $Result2["TelEdit"] . "\n ErrId= " . $Result2["ErrId"] . "\n\n-- ValidateTelephone [1] -- ( " . $Result2["TelEdit"] . " )" . "\n TelType= " . $Result3["TelType"] . "\n EditType= " . $Result3["EditType"] . "\n TelEdit= " . $Result3["TelEdit"] . "\n ErrId= " . $Result3["ErrId"] . "\n\n-- ValidateTelephone [2] -- ( " . $TelCode . " )" . "\n TelType= " . $Result4["TelType"] . "\n EditType= " . $Result4["EditType"] . "\n TelEdit= " . $Result4["TelEdit"] . "\n ErrId= " . $Result4["ErrId"] . "\n\n"); } } ?>
[ この場所へのリンク ]
---------- Perl 版 テストコード ----------
( Coloring by SyntaxHighlighter )
#!/usr/bin/perl use utf8; use strict; binmode STDOUT, ':encoding(UTF-8)'; ## TelphoneCheck.pl テスト ツール ## require 'TelephoneCheck.pl'; my $Ans = ""; my $Arg = ""; my @ArgList = ("",""); my $TelCode = ""; # テスト 電話番号 my %Result1 = InitTelephone("Type"); my %Result2 = InitTelephone("Value"); my %Result3 = InitTelephone("Value"); my %Result4 = InitTelephone("Value"); my $Result5 = ""; # PhoneNumber print STDOUT "Test of PhoneNumber? (Y/N) > "; $Ans = <STDIN>; chomp($Ans); if ((uc($Ans) ne "Y") && (uc($Ans) ne "N")) { print STDOUT "-- End of TelephoneCheck Test --\n\n"; exit; } if (uc($Ans) eq "Y") { # コンソールで何も入力せずに即リターンしたら終了 while (1) { print STDOUT "PhoneNumber [ TelCode , Action ] > "; $Arg = <STDIN>; # 電話番号,Action をコンソール入力 chomp($Arg); if ($Arg eq "") { print STDOUT "-- End of TelephoneCheck Test --\n\n"; last; } @ArgList = split(/,/, $Arg); if ($#ArgList != 1) { print STDOUT "Please enter [ TelCode , Action ]\n"; } else { $ArgList[0] =~ s/^\s*(.*?)\s*$/$1/; # Trim $ArgList[1] =~ s/^\s*(.*?)\s*$/$1/; # Trim $Result5 = PhoneNumber($ArgList[0], $ArgList[1]); if ($Result5) { print STDOUT "True [ " . $Result5 . " ]\n"; } else { print STDOUT "False [ " . $Result5 . " ]\n"; } } } } else { # コンソールで何も入力せずに即リターンしたら終了 while (1) { print STDOUT "TelPhoneCheck [ TelCode ] > "; $TelCode = <STDIN>; # 電話番号をコンソール入力 chomp($TelCode); if ($TelCode eq "") { print STDOUT "-- End of TelephoneCheck Test --\n\n"; last; } %Result1 = GetTypeTelephone($TelCode); # EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx %Result2 = FormatTelephone($TelCode, 1); %Result3 = ValidateTelephone($Result2{TelEdit}); # 編集電話番号 %Result4 = ValidateTelephone($TelCode); # 数字のみ電話番号 print STDOUT ("\n TelCode= [ " . $TelCode . " ]" . "\n-- GetTypeTelephone --" . "\n TelType= " . $Result1{TelType} . "\n SizeAll= " . $Result1{SizeAll} . "\n Size1= " . $Result1{Size1} . "\n Size2= " . $Result1{Size2} . "\n Size3= " . $Result1{Size3} . "\n ErrId= " . $Result1{ErrId} . "\n\n-- FormatTelephone --" . "\n TelType= " . $Result2{TelType} . "\n EditType= " . $Result2{EditType} . "\n TelEdit= " . $Result2{TelEdit} . "\n ErrId= " . $Result2{ErrId} . "\n\n-- ValidateTelephone [1] -- ( " . $Result2{TelEdit} . " )" . "\n TelType= " . $Result3{TelType} . "\n EditType= " . $Result3{EditType} . "\n TelEdit= " . $Result3{TelEdit} . "\n ErrId= " . $Result3{ErrId} . "\n\n-- ValidateTelephone [2] -- ( " . $TelCode . " )" . "\n TelType= " . $Result4{TelType} . "\n EditType= " . $Result4{EditType} . "\n TelEdit= " . $Result4{TelEdit} . "\n ErrId= " . $Result4{ErrId} . "\n\n"); } }
[ この場所へのリンク ]
---------- Python 版 テストコード ----------
( Coloring by SyntaxHighlighter )
#!/usr/bin/env python # -*- coding: utf-8 -*- ## TelphoneCheck.py テスト ツール ## import sys from TelephoneCheck import validate_telephone from TelephoneCheck import format_telephone from TelephoneCheck import get_type_telephone from TelephoneCheck import init_telephone from TelephoneCheck import phone_number ans = '' arg = '' arg_list = ["",""]; tel_code = '' # テスト 電話番号 result1 = init_telephone('Type') result2 = init_telephone('Value') result3 = init_telephone('Value') result4 = init_telephone('Value') result5 = '' # PhoneNumber ans = input('Test of PhoneNumber? (Y/N) > ') if ((ans.upper() != "Y") and (ans.upper() != "N")): print ('-- End of TelephoneCheck Test --\n\n') sys.exit(0) else: pass if (ans.upper() == "Y"): # コンソールで何も入力せずに即リターンしたら終了 while (True): arg = input('PhoneNumber [ TelCode , Action ] > ') # 電話番号,Action をコンソール入力 if (arg == ''): print ('-- End of TelephoneCheck Test --\n\n') break else: pass arg_list = arg.split(",") if (len(arg_list) != 2): print ('Please enter [ TelCode , Action ]\n') else: result5 = phone_number(arg_list[0].strip(), arg_list[1].strip()) print (str(bool(result5)) + " [ " + str(result5) + " ]\n") else: # コンソールで何も入力せずに即リターンしたら終了 while (True): tel_code = input('TelephoneCheck > ') # 電話番号をコンソール入力 if (tel_code == ''): print ('-- End of TelephoneCheck Test --\n\n') break result1 = get_type_telephone(tel_code) # EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx result2 = format_telephone(tel_code, 1) result3 = validate_telephone(result2['TelEdit']) # 編集電話番号 result4 = validate_telephone(tel_code) # 数字のみ電話番号 print ('\n TelCode= [ ' + str(tel_code) + ' ]' + '\n-- GetTypeTelephone --' + '\n TelType= ' + str(result1['TelType']) + '\n SizeAll= ' + str(result1['SizeAll']) + '\n Size1= ' + str(result1['Size1']) + '\n Size2= ' + str(result1['Size2']) + '\n Size3= ' + str(result1['Size3']) + '\n ErrId= ' + str(result1['ErrId']) + '\n\n-- FormatTelephone --' + '\n TelType= ' + str(result2['TelType']) + '\n EditType= ' + str(result2['EditType']) + '\n TelEdit= ' + str(result2['TelEdit']) + '\n ErrId= ' + str(result2['ErrId']) + '\n\n-- ValidateTelephone [1] -- ( ' + str(result2['TelEdit']) + ' )' + '\n TelType= ' + str(result3['TelType']) + '\n EditType= ' + str(result3['EditType']) + '\n TelEdit= ' + str(result3['TelEdit']) + '\n ErrId= ' + str(result3['ErrId']) + '\n\n-- ValidateTelephone [2] -- ( ' + str(tel_code) + ' )' + '\n TelType= ' + str(result4['TelType']) + '\n EditType= ' + str(result4['EditType']) + '\n TelEdit= ' + str(result4['TelEdit']) + '\n ErrId= ' + str(result4['ErrId']) + '\n\n')
[ この場所へのリンク ]
---------- Ruby 版 テストコード ----------
( Coloring by SyntaxHighlighter )
#! ruby -EUTF-8 # -*- mode:ruby; coding:utf-8 -*- ## TelphoneCheck.rb テスト ツール ## module PhoneCheckTest require './TelephoneCheck' ans = "" arg = "" arg_list = ["",""] tel_code = "" # テスト 電話番号 result1 = TelephoneCheck.init_telephone('Type') result2 = TelephoneCheck.init_telephone('Value') result3 = TelephoneCheck.init_telephone('Value') result4 = TelephoneCheck.init_telephone('Value') result5 = "" print ("Test of PhoneNumber? (Y/N) > ") ans = gets.chomp if ((ans.upcase != "Y") && (ans.upcase != "N")) print("-- End of TelephoneCheck Test --\n\n") exit end if (ans.upcase == "Y") # コンソールで何も入力せずに即リターンしたら終了 while (true) print ("PhoneNumber [ TelCode , Action ] > ") arg = gets.chomp # 電話番号,Action をコンソール入力 if (arg == "") print("-- End of TelephoneCheck Test --\n\n") break; end arg_list = arg.split(",") if (arg_list.length != 2) print("Please enter [ TelCode , Action ]\n") else result5 = TelephoneCheck.phone_number(arg_list[0].strip, arg_list[1].strip) if (result5) print("TRUE [ " + result5.to_s + " ]\n") else print("FALSE [ " + result5.to_s + " ]\n") end end end else # コンソールで何も入力せずに即リターンしたら終了 while (true) print("TelephoneCheck > ") tel_code = gets.chomp # 電話番号をコンソール入力 if (tel_code == "") print("-- End of TelephoneCheck Test --\n\n") break end result1 = TelephoneCheck.get_type_telephone(tel_code) # EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx result2 = TelephoneCheck.format_telephone(tel_code, 1) result3 = TelephoneCheck.validate_telephone(result2[:TelEdit]) # 編集電話番号 result4 = TelephoneCheck.validate_telephone(tel_code) # 数字のみ電話番号 print("\n TelCode= [ " + tel_code.to_s + " ]" + "\n-- GetTypeTelephone --" + "\n TelType= " + result1[:TelType].to_s + "\n SizeAll= " + result1[:SizeAll].to_s + "\n Size1= " + result1[:Size1].to_s + "\n Size2= " + result1[:Size2].to_s + "\n Size3= " + result1[:Size3].to_s + "\n ErrId= " + result1[:ErrId].to_s + "\n\n-- FormatTelephone --" + "\n TelType= " + result2[:TelType].to_s + "\n EditType= " + result2[:EditType].to_s + "\n TelEdit= " + result2[:TelEdit].to_s + "\n ErrId= " + result2[:ErrId].to_s + "\n\n-- ValidateTelephone [1] -- ( " + result2[:TelEdit].to_s + " )" + "\n TelType= " + result3[:TelType].to_s + "\n EditType= " + result3[:EditType].to_s + "\n TelEdit= " + result3[:TelEdit].to_s + "\n ErrId= " + result3[:ErrId].to_s + "\n\n-- ValidateTelephone [2] -- ( " + tel_code.to_s + " )" + "\n TelType= " + result4[:TelType].to_s + "\n EditType= " + result4[:EditType].to_s + "\n TelEdit= " + result4[:TelEdit].to_s + "\n ErrId= " + result4[:ErrId].to_s + "\n\n") end end end # of module
[ この場所へのリンク ]
---------- VBA / VB6 版 テストコード ----------
イミディエイトウィンドウ で テスト します。
?PhoneNumber("0345671234", "F1") 等
下記 テストマクロ の場合 ?TelephoneTest("0345671234") 等
PhoneNumber 関数はワークシート上でもテストできます。
[ A1 (書式:文字列) ] 0345671234 [ B1 ] F1 [ C1 ] =PhoneNumber(A1, B1)
Excel 向けアドイン [ PhoneNumberAddin.xla ] を ダウンロード に用意してあります。
( Coloring by SyntaxHighlighter )
Public Function TelephoneTest(ByVal TelCode As String) Dim Result1 As TelephoneStruct Dim Result2 As TelephoneStruct Dim Result3 As TelephoneStruct Dim Result4 As TelephoneStruct Dim Msg1 As String Dim Msg2 As String Dim Msg3 As String Dim Msg4 As String If (TelCode = "") Then Exit Function End If Result1 = InitTelephone() Result2 = InitTelephone() Result3 = InitTelephone() Result4 = InitTelephone() Result1 = GetTypeTelephone(TelCode) '// EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx Result2 = FormatTelephone(TelCode, 1) Result3 = ValidateTelephone(Result2.TelEdit) '// 編集電話番号 Result4 = ValidateTelephone(TelCode) '// 数字のみ電話番号 Msg1 = vbCrLf & " TelCode= [ " & TelCode & " ]" & _ vbCrLf & _ vbCrLf & "-- GetTypeTelephone --" & _ vbCrLf & " TelType= " & Result1.TelType & _ vbCrLf & " SizeAll= " & Result1.SizeAll & _ vbCrLf & " Size1= " & Result1.Size1 & _ vbCrLf & " Size2= " & Result1.Size2 & _ vbCrLf & " Size3= " & Result1.Size3 & _ vbCrLf & " ErrId= " & Result1.ErrId Msg2 = vbCrLf & _ vbCrLf & " -- FormatTelephone --" & _ vbCrLf & " TelType= " & Result2.TelType & _ vbCrLf & " EditType= " & Result2.EditType & _ vbCrLf & " TelEdit= " & Result2.TelEdit & _ vbCrLf & " ErrId= " & Result2.ErrId Msg3 = vbCrLf & _ vbCrLf & " -- ValidateTelephone [1] -- ( " & Result2.TelEdit & " )" & _ vbCrLf & " TelType= " & Result3.TelType & _ vbCrLf & " EditType= " & Result3.EditType & _ vbCrLf & " TelEdit= " & Result3.TelEdit & _ vbCrLf & " ErrId= " & Result3.ErrId Msg4 = vbCrLf & _ vbCrLf & " -- ValidateTelephone [2] -- ( " & TelCode & " )" & _ vbCrLf & " TelType= " & Result4.TelType & _ vbCrLf & " EditType= " & Result4.EditType & _ vbCrLf & " TelEdit= " & Result4.TelEdit & _ vbCrLf & " ErrId= " & Result4.ErrId Debug.Print Msg1 & Msg2 & Msg3 & Msg4 End Function
[ この場所へのリンク ]
---------- VB.net 版 テストコード ----------
下記コードは「コンソール アプリ」として作ってあります。
( Coloring by SyntaxHighlighter )
Option Explicit On Imports TelephoneCheck Module PhoneTest Public Sub Main() Dim Result1 As New TelephoneType(0) Dim Result2 As New TelephoneCheckValue(0) Dim Result3 As New TelephoneCheckValue(0) Dim Result4 As New TelephoneCheckValue(0) Dim Msg1 As String Dim Msg2 As String Dim Msg3 As String Dim Msg4 As String Dim Ans As String = "Start" Dim ArgList() As String Dim cnt As Integer = 0 Console.WriteLine(vbCrLf & " --- Start of PoneTest ---") While (Ans <> String.Empty) Console.WriteLine(vbCrLf & " --------------------------------------" & vbCrLf & " PhoneNumber(検証): 編集電話番号,V" & vbCrLf & " PhoneNumber(編集): 電話番号,n (n=1〜6)" & vbCrLf & " 全体テスト : 電話番号のみ" & vbCrLf & " --------------------------------------" & vbCrLf & " Phone Test >> ") Ans = Console.ReadLine() If (Ans = String.Empty) Then Continue While End If ArgList = Split(Ans, ",") Select Case ArgList.Length Case 1 Result1 = GetTypeTelephone(ArgList(0)) '// EditType 1: xx-xx-xx , 2: xx(xx)xx , 3: (xx)xx-xx Result2 = FormatTelephone(ArgList(0), 1) Result3 = ValidateTelephone(Result2.TelEdit) '// 編集電話番号 Result4 = ValidateTelephone(ArgList(0)) '// 数字のみ電話番号 Msg1 = vbCrLf & " TelCode= [ " & ArgList(0) & " ]" & vbCrLf & vbCrLf & " -- GetTypeTelephone --" & vbCrLf & " TelType= " & CStr(Result1.TelType) & vbCrLf & " SizeAll= " & CStr(Result1.SizeAll) & vbCrLf & " Size1= " & CStr(Result1.Size1) & vbCrLf & " Size2= " & CStr(Result1.Size2) & vbCrLf & " Size3= " & CStr(Result1.Size3) & vbCrLf & " ErrId= " & CStr(Result1.ErrId) Msg2 = vbCrLf & vbCrLf & " -- FormatTelephone --" & vbCrLf & " TelType= " & CStr(Result2.TelType) & vbCrLf & " EditType= " & CStr(Result2.EditType) & vbCrLf & " TelEdit= " & CStr(Result2.TelEdit) & vbCrLf & " ErrId= " & CStr(Result2.ErrId) Msg3 = vbCrLf & vbCrLf & " -- ValidateTelephone [1] -- ( " & CStr(Result2.TelEdit) & " )" & vbCrLf & " TelType= " & CStr(Result3.TelType) & vbCrLf & " EditType= " & CStr(Result3.EditType) & vbCrLf & " TelEdit= " & CStr(Result3.TelEdit) & vbCrLf & " ErrId= " & CStr(Result3.ErrId) Msg4 = vbCrLf & vbCrLf & " -- ValidateTelephone [2] -- ( " & ArgList(0) & " )" & vbCrLf & " TelType= " & CStr(Result4.TelType) & vbCrLf & " EditType= " & CStr(Result4.EditType) & vbCrLf & " TelEdit= " & CStr(Result4.TelEdit) & vbCrLf & " ErrId= " & CStr(Result4.ErrId) Console.WriteLine(Msg1 & Msg2 & Msg3 & Msg4 & vbCrLf & vbCrLf) Case 2 Select Case ArgList(1).ToUpper Case "V" Console.WriteLine(" PhoneNumber => " & PhoneNumber(ArgList(0)) & " [ CBool => " & CBool(PhoneNumber(ArgList(0))) & " ]") Case "1" To "6" Console.WriteLine(" PhoneNumber => " & PhoneNumber(ArgList(0), CInt(ArgList(1)))) Case Else Continue While End Select Case Else Continue While End Select End While Console.WriteLine(" --- End of PoneTest ---" & vbCrLf & " コンソールを閉じるには何かキーを押してください...") Console.ReadKey() End Sub End Module
[ Excel_Tipe29 へ戻る ]
角田 桂一 Mail:addinbox@h4.dion.ne.jp CopyRight(C) 2019 Allrights Reserved.