| 
    
     |  | ▼HyperVTEC さん: >了解しました。
 >どうも有難うございました!
 ちょっと遅かったみたいですねえ・・・。
 
 一応考えてみました。但し、この場合、最初の文字列をJISコード変換するコードから
 変更しなければなりません。つまり、制御コードも入れるということです。
 JISコード自体もう何年も扱っていないので忘れてしまっているところもありますが。
 以下のコードは、
 Userform1にTextbox1、Textbox2、Textbox3と
 Commandbutton1とCommandbutton2を貼り付けてください。
 
 仕様は、Commandbutton1クリックでTextbox1の文字列をJISコード変換してTextbox2
 に表示、Commandbutton2クリックでTextbox2を入力データとして文字列変換したものを
 Textbox3に表示します。
 
 userform1のモジュールに
 
 '============================================
 Const ki As String = "000110110010010001000010"
 Const ko As String = "000110110010100001001010"
 '================================================
 Private Sub CommandButton1_Click()
 Dim kj As Boolean
 Dim bitnum
 Dim wk As Long
 TextBox2.Text = ""
 kj = False
 With TextBox1
 i = 1
 Do While i <= Len(.Text)
 If LenB(StrConv(Mid(.Text, i, 1), vbFromUnicode)) = 1 Then
 If kj = True Then
 TextBox2.Text = TextBox2.Text & ko
 kj = False
 End If
 bitnum = 8
 Else
 If kj = False Then
 TextBox2.Text = TextBox2.Text & ki
 kj = True
 End If
 bitnum = 16
 End If
 If Mid$(.Text, i, 1) = Chr(-32408) Then
 wk = 8521
 Else
 wk = Evaluate("code(""" & Mid$(.Text, i, 1) & """)")
 End If
 TextBox2.Text = TextBox2.Text & sp_dec2bin(wk, bitnum)
 i = i + 1
 Loop
 If kj = True Then TextBox2.Text = TextBox2.Text & ko
 End With
 End Sub
 '==============================================================
 Function sp_dec2bin(dnum, Optional scl = 8) As Variant
 '機能  数値を2進数文字列に変換する
 'input dnum 変換する数値
 '    scl 2進数の桁数
 'output sp_dec2bin 2進数文字列
 Dim wk As Long
 wk = dnum
 sp_dec2bin = ""
 For idx = scl - 1 To 0 Step -1
 ans = wk And (2 ^ idx)
 sp_dec2bin = sp_dec2bin & IIf(ans > 0, 1, 0)
 Next idx
 End Function
 '========================================================
 Function sp_bin2dec(binstr) As Long
 '機能  指定された2進数文字列を数値に変換する
 'input binstr 2進数文字列
 'output sp_bin2dec 変換数値
 Dim l_str As Long
 l_str = Len(binstr)
 sp_bin2dec = 0
 For idx = 1 To l_str
 sp_bin2dec = sp_bin2dec + Mid(binstr, idx, 1) * (2 ^ (l_str - idx))
 Next idx
 End Function
 '====================================================
 Private Sub CommandButton2_Click()
 Dim kj As Boolean
 Dim bitnum
 Dim wk As String
 kj = False
 With TextBox3
 .Text = ""
 wk = get_byte(TextBox2.Text)
 Do While wk <> ""
 If sp_bin2dec(wk) = 27 Then
 wk = wk & get_byte() & get_byte()
 If wk = ki Then
 kj = True
 ElseIf wk = ko Then
 kj = False
 End If
 Else
 If kj = True Then
 wk = wk & get_byte()
 End If
 .Text = .Text & Evaluate("char(" & sp_bin2dec(wk) & ")")
 End If
 wk = get_byte()
 Loop
 End With
 End Sub
 '===========================================================
 Function get_byte(Optional b_str = "") As Variant
 '機能  指定された2進数文字列を1バイトづつ取り出す
 'input b_str(2回目以降の呼び出しでは指定しない)
 'output get_byte 1バイト分の2進数文字列 ""の場合、データの終わり
 Static sv_str
 Static c_idx As Long
 If b_str <> "" Then
 sv_str = b_str
 c_idx = 1
 End If
 If Len(Mid(sv_str, c_idx)) < 8 Then
 get_byte = ""
 Else
 get_byte = Mid(sv_str, c_idx, 8)
 c_idx = c_idx + 8
 End If
 End Function
 
 
 但し、Commandbutton1をクリックしたことにより、変換された2進数文字列以外は
 逆変換はできませんので、ご了承ください。
 
 
 |  |