|
6#
楼主 |
发表于 2007-8-4 13:04:41
|
只看该作者
加上以下代码好似可以达到2楼的第一个要求, 代码只做了简单测试,可能也会有不符合汉语拼音规则的地方,代码做的也比较烂,还是希望sgrshh29 能奉献一个2楼那个源码。
Public Function ZH(str As String)
Dim aa() As String
Dim a As String
Dim o As String
Dim e As String
Dim i As String
Dim u As String
Dim v As String
Dim k, kk As Integer
Dim T, j As Integer
a = "āáǎà"
o = "ōóǒò"
e = "ēéěè"
i = "īíǐì"
u = "ūúǔù"
v = "ǖǘǚǜ"
aa() = Split(PinyinConvers(str), " ")
For T = 0 To UBound(aa())
zhstr = aa(T)
k = 0
kk = 0
For j = 1 To Len(zhstr)
If InStr("aoeiuv", Mid(zhstr, j, 1)) > 0 Then
k = k + 1
If k > 1 Then
If Mid(zhstr, kk, 1) = "u" Then
ntstr = Left(zhstr, j - 1) & IIf(Mid(zhstr, j, 1) = "a", Mid(a, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "o", Mid(o, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "e", Mid(e, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "e", Mid(e, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "i", Mid(i, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "u", Mid(u, Right(zhstr, 1), 1), Mid(v, Right(zhstr, 1), 1))))))) & Mid(zhstr, j + 1, Len(zhstr) - j - 1)
End If
Else
ntstr = Left(zhstr, j - 1) & IIf(Mid(zhstr, j, 1) = "a", Mid(a, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "o", Mid(o, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "e", Mid(e, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "e", Mid(e, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "i", Mid(i, Right(zhstr, 1), 1), IIf(Mid(zhstr, j, 1) = "u", Mid(u, Right(zhstr, 1), 1), Mid(v, Right(zhstr, 1), 1))))))) & Mid(zhstr, j + 1, Len(zhstr) - j - 1)
kk = j
End If
End If
Next j
If zhstr <> "" Then nstr = nstr & " " & ntstr
Next
ZH = nstr
End Function |
|