Option Explicit Dim objFSO,objTxt,objWShell Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set objTxt = objFSO.OpenTextFile("test1.txt", ForAppending, true, -2) Set objWShell = WScript.CreateObject("WScript.Shell") Dim strInput '入力文字コード Dim strHex '並び替えた文字 Dim strCode '並び替えた文字を動的配列へ '文字コード入力 myInput objTxt.WriteLine "入力コード : " & strInput '文字数確認 If Len(strInput) > 253 Then myNagasugi '並べ替え myNarabikae objTxt.WriteLine "並べ替えコード : " & strHex '並べ替えコードを配列変数に myHairetu(strHex) '文字に変換 objTxt.Write "変換文字列 : " myHenkan objTxt.WriteBlankLines (2) 'objTxtをクローズしてテキストエディタでを開く objTxt.Close objWShell.Run "test1.txt" 'オブジェクトを破棄 Set objWShell = Nothing Set objTxt = Nothing Set objFSO = Nothing '********************************************************* '* Sub myInput '********************************************************* Sub myInput strInput = InputBox("変換するカンマ区切りの符号を入力", "REG_EXPAND_SZ値を文字に変換") If IsEmpty(strInput) Then WScript.Quit If strInput = "" Then myInput Else myEcho End If End Sub '********************************************************* '* Sub myEcho '********************************************************* Sub myEcho Dim intStr, intStrB '文字数、バイト数 intStr = Len(strInput) intStrB = LenB(strInput) If intStr > 253 Then intStr = "254文字 オーバー" If intStrB > 507 Then intStrB = "508バイト オーバー" WScript.Echo " * 変数名 : ", "strInput",vbCrLf, _ " * 値 : ", strInput, vbCrLf, vbCrLf, _ " * 型 : ", TypeName(strInput), vbCrLf, _ " * 文字数 : ", intStr, vbCrLf, _ " * バイト : ", intStrB End Sub '********************************************************* '* Sub myNarabikae '********************************************************* Sub myNarabikae Dim x,y,z,numMojisu numMojisu = Len(strInput) - 1 For x = 4 to numMojisu Step 6 y = x-3 z = Mid(strInput, x, 2) & Mid(strInput, y, 2) strHex = strHex & z & "," Next MsgBox "並び替え : " & vbCrLf & vbCrLf & strHex End Sub '********************************************************* '* Sub myHairetu '********************************************************* '入力コードを配列変数に Sub myHairetu(myStr) strCode = split(myStr, ",", -1, 1) End Sub '********************************************************* '* Sub myHenkan '********************************************************* Sub myHenkan Dim t For Each t in (strCode) On Error Resume Next t = CLng("&H" & t) '&Hを足す t = ChrW(t) '&Hxxxx をユニコード文字に変換 objTxt.Write t On Error Goto 0 Next End Sub '********************************************************* '* Sub myNagasugi '********************************************************* 'Sub Sub myNagasugi WScript.Echo "入力データが長すぎます...", vbCrLf, _ "253文字以下に分割してください。" objTxt.Close Set objWShell = Nothing Set objTxt = Nothing Set objFSO = Nothing WScript.Quit End Sub