Function JisToStr(ByVal Str As String, Nbr As Integer) As String
On Error Resume Next
Dim Stm As ADODB.Stream
Dim StrByt() As Byte
Dim n01 As Integer
Dim m01 As Integer
Dim Asr01Str As String
Set Stm = New ADODB.Stream
Asr01Str = ""
m01 = 0
For n01 = 1 To Nbr Step 2
If Mid(Str, n01, 1) = "#" Then
Asr01Str = Asr01Str & Mid(Str, n01 + 1, 1)
ElseIf Mid(Str, n01, 1) = "" Then
Exit For
Else
ReDim StrByt(7)
StrByt(0) = 27
StrByt(1) = 36
StrByt(2) = 66
StrByt(3) = Asc(Mid(Str, n01, 1))
StrByt(4) = Asc(Mid(Str, n01 + 1, 1))
StrByt(5) = 27
StrByt(6) = 40
StrByt(7) = 66
If Err.Number = 3705 Then
Stm.Close
End If
Stm.Open
Stm.Type = adTypeBinary
Stm.Write StrByt
Stm.Position = 0
Stm.Type = adTypeText
Stm.Charset = "iso-2022-jp" '僶僀僩僨乕僞偺暥帤僐乕僪傪巜?
Asr01Str = Asr01Str & Stm.ReadText() 'String宆偺僨乕僞偲偟偰庢傝弌?
Stm.Close
End If
Next n01
Set Stm = Nothing
JisToStr = Asr01Str
End Function
'====================================
Function StrToJis(ByVal Str As String) As String
On Error Resume Next
Dim Stm As ADODB.Stream
Dim StrByt() As Byte
Dim Str01Nbr As Integer
Dim n01 As Integer
Dim m01 As Integer
Dim Asr01Str As String
Dim Asr02Str As String
Dim A As Byte
Dim C As Byte
'JIS僐乕僪偺僗僩儕乕儉傪嶌?
Set Stm = New ADODB.Stream
Str01Nbr = Len(Str)
Asr01Str = ""
Asr02Str = ""
For n01 = 1 To Str01Nbr
'暥帤楍傪奿擺
If Err.Number = 3705 Then
Stm.Close
End If
Stm.Open
On Error Resume Next
Dim Stm As ADODB.Stream
Dim StrByt() As Byte
Dim n01 As Integer
Dim m01 As Integer
Dim Asr01Str As String
Set Stm = New ADODB.Stream
Asr01Str = ""
m01 = 0
For n01 = 1 To Nbr Step 2
If Mid(Str, n01, 1) = "#" Then
Asr01Str = Asr01Str & Mid(Str, n01 + 1, 1)
ElseIf Mid(Str, n01, 1) = "" Then
Exit For
Else
ReDim StrByt(7)
StrByt(0) = 27
StrByt(1) = 36
StrByt(2) = 66
StrByt(3) = Asc(Mid(Str, n01, 1))
StrByt(4) = Asc(Mid(Str, n01 + 1, 1))
StrByt(5) = 27
StrByt(6) = 40
StrByt(7) = 66
If Err.Number = 3705 Then
Stm.Close
End If
Stm.Open
Stm.Type = adTypeBinary
Stm.Write StrByt
Stm.Position = 0
Stm.Type = adTypeText
Stm.Charset = "iso-2022-jp" '僶僀僩僨乕僞偺暥帤僐乕僪傪巜?
Asr01Str = Asr01Str & Stm.ReadText() 'String宆偺僨乕僞偲偟偰庢傝弌?
Stm.Close
End If
Next n01
Set Stm = Nothing
JisToStr = Asr01Str
End Function
'====================================
Function StrToJis(ByVal Str As String) As String
On Error Resume Next
Dim Stm As ADODB.Stream
Dim StrByt() As Byte
Dim Str01Nbr As Integer
Dim n01 As Integer
Dim m01 As Integer
Dim Asr01Str As String
Dim Asr02Str As String
Dim A As Byte
Dim C As Byte
'JIS僐乕僪偺僗僩儕乕儉傪嶌?
Set Stm = New ADODB.Stream
Str01Nbr = Len(Str)
Asr01Str = ""
Asr02Str = ""
For n01 = 1 To Str01Nbr
'暥帤楍傪奿擺
If Err.Number = 3705 Then
Stm.Close
End If
Stm.Open
Stm.Type = adTypeText
Stm.Charset = "iso-2022-jp" '"iso-2022-jp" '偁傞偄偼"Shift_JIS"傗"EUC-JP"偲?
Stm.WriteText Mid(Str, n01, 1)
Stm.Charset = "iso-2022-jp" '"iso-2022-jp" '偁傞偄偼"Shift_JIS"傗"EUC-JP"偲?
Stm.WriteText Mid(Str, n01, 1)
'JIS僐乕僪偺僶僀僫儕偲偟偰庢?
Stm.Position = 0
Stm.Type = adTypeBinary
StrByt = Stm.Read()
m01 = UBound(StrByt)
A = StrByt(0)
C = StrByt(1)
Stm.Position = 0
Stm.Type = adTypeBinary
StrByt = Stm.Read()
m01 = UBound(StrByt)
A = StrByt(0)
C = StrByt(1)
If UBound(StrByt) = 0 Then
Asr01Str = Asr01Str & "#" & String(1, StrByt(0))
ElseIf m01 = 1 Then
A = StrByt(0)
C = StrByt(1)
Asr01Str = Asr01Str & String(1, StrByt(1))
Else
Asr02Str = StrByt(0) & StrByt(1) & StrByt(2) & StrByt(3) & StrByt(4) & StrByt(5) & StrByt(6) & StrByt(7)
Asr01Str = Asr01Str & String(1, StrByt(3)) & String(1, StrByt(4))
End If
Stm.Close
Next n01
Set Stm = Nothing
Asr01Str = Asr01Str & "#" & String(1, StrByt(0))
ElseIf m01 = 1 Then
A = StrByt(0)
C = StrByt(1)
Asr01Str = Asr01Str & String(1, StrByt(1))
Else
Asr02Str = StrByt(0) & StrByt(1) & StrByt(2) & StrByt(3) & StrByt(4) & StrByt(5) & StrByt(6) & StrByt(7)
Asr01Str = Asr01Str & String(1, StrByt(3)) & String(1, StrByt(4))
End If
Stm.Close
Next n01
Set Stm = Nothing
StrToJis = Asr01Str
End Function
End Function