|
考え過ぎで、こっちの方が速い見たい?
Public Function GetPurpose(ByVal strMark As String) As String
Dim i As Long
Dim strResult As String
Dim strLetter As String
Dim blnWide As Boolean
Dim strReplace As String
If strMark = "" Then
Exit Function
End If
strMark = StrConv(strMark, vbNarrow)
strReplace = "-"
For i = 1 To Len(strMark)
strLetter = Mid(strMark, i, 1)
If LenB(StrConv(strLetter, vbFromUnicode)) <> 2 _
And strLetter <> strReplace Then
blnWide = False
strResult = strResult & strLetter
Else
If Not blnWide Then
blnWide = True
strResult = strResult & strReplace
End If
End If
Next i
If blnWide Then
strResult = Left(strResult, Len(strResult) - 1)
End If
GetPurpose = strResult
End Function
|
|