MSアクセスで作って運用していたデータベースを MySQL に移行中です.
このデータベース、20年ほど前に原型が作られました.
まだアクセスがなかったころで、懐かしの dbase2 で作られていたのですよ.
その頃はまだ、カタカナは半角で入力するのが当然と言った頃でした.
その名残を引きずっているため、まだ半角カナでのデータだらけなのよ.
そんな半角カナを全角カナにうまく変換してくれる関数がアクセスにないようなのです.
ググってみたものの良いのが出てこない(T_T).
仕方がないので自作しました.
Option Compare Database
Function myHenkan(strData As String)
Dim i As Long, strTemp As String, OneString, TwoString
For i = 1 To Len(strData)
OneString = Mid(strData, i, 1)
If StrComp(OneString, "ア", 0) = 0 Then
OneString = "ア"
ElseIf StrComp(OneString, "イ", 0) = 0 Then
OneString = "イ"
ElseIf StrComp(OneString, "ウ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ヴ" Then
OneString = "ヴ"
i = i + 1
Else
OneString = "ウ"
End If
ElseIf StrComp(OneString, "エ", 0) = 0 Then
OneString = "エ"
ElseIf StrComp(OneString, "オ", 0) = 0 Then
OneString = "オ"
ElseIf StrComp(OneString, "カ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ガ" Then
OneString = "ガ"
i = i + 1
Else
OneString = "カ"
End If
ElseIf StrComp(OneString, "キ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ギ" Then
OneString = "ギ"
i = i + 1
Else
OneString = "キ"
End If
ElseIf StrComp(OneString, "ク", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "グ" Then
OneString = "グ"
i = i + 1
Else
OneString = "ク"
End If
ElseIf StrComp(OneString, "ケ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ゲ" Then
OneString = "ゲ"
i = i + 1
Else
OneString = "ケ"
End If
ElseIf StrComp(OneString, "コ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ゴ" Then
OneString = "ゴ"
i = i + 1
Else
OneString = "コ"
End If
ElseIf StrComp(OneString, "サ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ザ" Then
OneString = "ザ"
i = i + 1
Else
OneString = "サ"
End If
ElseIf StrComp(OneString, "シ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ジ" Then
OneString = "ジ"
i = i + 1
Else
OneString = "シ"
End If
ElseIf StrComp(OneString, "ス", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ズ" Then
OneString = "ズ"
i = i + 1
Else
OneString = "ス"
End If
ElseIf StrComp(OneString, "セ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ゼ" Then
OneString = "ゼ"
i = i + 1
Else
OneString = "セ"
End If
ElseIf StrComp(OneString, "ソ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ゾ" Then
OneString = "ゾ"
i = i + 1
Else
OneString = "ソ"
End If
ElseIf StrComp(OneString, "タ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ダ" Then
OneString = "ダ"
i = i + 1
Else
OneString = "タ"
End If
ElseIf StrComp(OneString, "チ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ヂ" Then
OneString = "ヂ"
i = i + 1
Else
OneString = "チ"
End If
ElseIf StrComp(OneString, "ツ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ヅ" Then
OneString = "ヅ"
i = i + 1
Else
OneString = "ツ"
End If
ElseIf StrComp(OneString, "テ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "デ" Then
OneString = "デ"
i = i + 1
Else
OneString = "テ"
End If
ElseIf StrComp(OneString, "ト", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ド" Then
OneString = "ド"
i = i + 1
Else
OneString = "ト"
End If
ElseIf StrComp(OneString, "ナ", 0) = 0 Then
OneString = "ナ"
ElseIf StrComp(OneString, "ニ", 0) = 0 Then
OneString = "ニ"
ElseIf StrComp(OneString, "ヌ", 0) = 0 Then
OneString = "ヌ"
ElseIf StrComp(OneString, "ネ", 0) = 0 Then
OneString = "ネ"
ElseIf StrComp(OneString, "ノ", 0) = 0 Then
OneString = "ノ"
ElseIf StrComp(OneString, "ハ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "パ" Then
OneString = "パ"
i = i + 1
ElseIf TwoString = "バ" Then
OneString = "バ"
i = i + 1
Else
OneString = "ハ"
End If
ElseIf StrComp(OneString, "ヒ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ピ" Then
OneString = "ピ"
i = i + 1
ElseIf TwoString = "ビ" Then
OneString = "ビ"
i = i + 1
Else
OneString = "ヒ"
End If
ElseIf StrComp(OneString, "フ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "プ" Then
OneString = "プ"
i = i + 1
ElseIf TwoString = "ブ" Then
OneString = "ブ"
i = i + 1
Else
OneString = "フ"
End If
ElseIf StrComp(OneString, "ヘ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ペ" Then
OneString = "ペ"
i = i + 1
ElseIf TwoString = "ベ" Then
OneString = "ベ"
i = i + 1
Else
OneString = "ヘ"
End If
ElseIf StrComp(OneString, "ホ", 0) = 0 Then
TwoString = Mid(strData, i, 2)
If TwoString = "ポ" Then
OneString = "ポ"
i = i + 1
ElseIf TwoString = "ボ" Then
OneString = "ボ"
i = i + 1
Else
OneString = "ホ"
End If
ElseIf StrComp(OneString, "マ", 0) = 0 Then
OneString = "マ"
ElseIf StrComp(OneString, "ミ", 0) = 0 Then
OneString = "ミ"
ElseIf StrComp(OneString, "ム", 0) = 0 Then
OneString = "ム"
ElseIf StrComp(OneString, "メ", 0) = 0 Then
OneString = "メ"
ElseIf StrComp(OneString, "モ", 0) = 0 Then
OneString = "モ"
ElseIf StrComp(OneString, "ヤ", 0) = 0 Then
OneString = "ヤ"
ElseIf StrComp(OneString, "ユ", 0) = 0 Then
OneString = "ユ"
ElseIf StrComp(OneString, "ヨ", 0) = 0 Then
OneString = "ヨ"
ElseIf StrComp(OneString, "ラ", 0) = 0 Then
OneString = "ラ"
ElseIf StrComp(OneString, "リ", 0) = 0 Then
OneString = "リ"
ElseIf StrComp(OneString, "ル", 0) = 0 Then
OneString = "ル"
ElseIf StrComp(OneString, "レ", 0) = 0 Then
OneString = "レ"
ElseIf StrComp(OneString, "ロ", 0) = 0 Then
OneString = "ロ"
ElseIf StrComp(OneString, "ワ", 0) = 0 Then
OneString = "ワ"
ElseIf StrComp(OneString, "ヲ", 0) = 0 Then
OneString = "ヲ"
ElseIf StrComp(OneString, "ン", 0) = 0 Then
OneString = "ン"
ElseIf StrComp(OneString, "ァ", 0) = 0 Then
OneString = "ァ"
ElseIf StrComp(OneString, "ィ", 0) = 0 Then
OneString = "ィ"
ElseIf StrComp(OneString, "ゥ", 0) = 0 Then
OneString = "ゥ"
ElseIf StrComp(OneString, "ェ", 0) = 0 Then
OneString = "ェ"
ElseIf StrComp(OneString, "ォ", 0) = 0 Then
OneString = "ォ"
ElseIf StrComp(OneString, "ッ", 0) = 0 Then
OneString = "ッ"
ElseIf StrComp(OneString, "ャ", 0) = 0 Then
OneString = "ャ"
ElseIf StrComp(OneString, "ュ", 0) = 0 Then
OneString = "ュ"
ElseIf StrComp(OneString, "ョ", 0) = 0 Then
OneString = "ョ"
ElseIf StrComp(OneString, "「", 0) = 0 Then
OneString = "「"
ElseIf StrComp(OneString, "」", 0) = 0 Then
OneString = "」"
ElseIf StrComp(OneString, "。", 0) = 0 Then
OneString = "。"
ElseIf StrComp(OneString, "、", 0) = 0 Then
OneString = "、"
ElseIf StrComp(OneString, "ー", 0) = 0 Then
OneString = "ー"
ElseIf StrComp(OneString, "・", 0) = 0 Then
OneString = "・"
Else
OneString = OneString
End If
strTemp = strTemp & OneString
Next i
myHenkan = strTemp
End Function