马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
有专家说:java不是跨平台,java就是平台,这很好的定义了java的特点。有了java,你只需要等待java平台在新平台上移植。这还不错吧!只是,java不是一个平台,而是多个平台。你需要在这个java平台移植到另一个java平台。#Region"由拼音到拼音"
PublicSharedFunctionGetPyToPy(ByValPYStrAsString,_
OptionalByValIsCompAsBoolean=False)AsString
IfPYStr.Length=0ThenExitFunction
mIsCompelled=IsComp
DimtoneSiteAsInteger
DimtoneValueAsInteger
DimtoneCharAsChar
toneSite=GetToneSite(PYStr)
IftoneSite=-1Then
ReturnPYStr
ElseIftoneSite<-1Then
ExitFunction
EndIf
toneValue=GetToneValue(PYStr,toneSite)
IftoneValue=-1ThenExitFunction
IfmIsCompelledThen
toneChar=GetToneChar(PYStr,toneSite-1)
Else
toneChar=GetToneChar(PYStr)
EndIf
IfNotisPyChar(toneChar)ThenExitFunction
ReturnConversion(PYStr,toneSite,toneValue,toneChar)
EndFunction
前往标明腔调数值的地位
PrivateSharedFunctionGetToneSite(ByValpyStrAsString)AsInteger
IfpyStr.Length=0ThenExitFunction
DimiAsInteger,jAsInteger=0
反省字串中有几个数字
Fori=0TopyStr.Length-1
IfChar.IsNumber(pyStr.Chars(i))Then
j+=1
EndIf
Next
Ifj=0Then没无数字,即没有标明腔调的数值
Return-1
ElseIfj=1Then有一个数字,正当
Fori=0TopyStr.Length-1
IfChar.IsNumber(pyStr.Chars(i))Then
Returni
EndIf
Next
Else有多个数字,分歧法,前往其相反数
Return-j
EndIf
EndFunction
前往腔调是几声
PrivateSharedFunctionGetToneValue(ByValpyStrAsString,_
ByValSiteAsInteger)AsInteger
IfpyStr.Length=0ThenExitFunction
IfSite>=0Then
DimvalueAsChar=pyStr.Chars(Site)
DimnumAsInteger
IfChar.IsNumber(value)Then
num=CType(value.ToString,Integer)
Ifnum>=0Andnum<=4Then
Returnnum
Else
Return-1
EndIf
Else
Return-1
EndIf
EndIf
EndFunction
前往要标腔调的字母
PrivateSharedFunctionGetToneChar(ByValpyStrAsString,_
ByValSiteAsInteger)AsChar
IfpyStr.Length=0ThenExitFunction
IfSite>=0Then
DimvalueAsChar=pyStr.Chars(Site)
Returnvalue
EndIf
EndFunction
PrivateSharedFunctionGetToneChar(ByValpyStrAsString)AsChar
IfpyStr.Length=0ThenExitFunction
DimChrAsChar
IfpyStr.IndexOf(a(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(a(0)))
ElseIfpyStr.IndexOf(o(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(o(0)))
ElseIfpyStr.IndexOf(e(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(e(0)))
ElseIfpyStr.IndexOf(i(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(i(0)))
ElseIfpyStr.IndexOf(u(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(u(0)))
ElseIfpyStr.IndexOf(v(0))>=0Then
Chr=pyStr.Chars(pyStr.IndexOf(v(0)))
EndIf
ReturnChr
EndFunction
判别是不是为正当的拼音字符
PrivateSharedFunctionisPyChar(ByValchrAsChar)AsBoolean
SelectCasechr
Case"a"c
ReturnTrue
Case"o"c
ReturnTrue
Case"e"c
ReturnTrue
Case"i"c
ReturnTrue
Case"u"c
ReturnTrue
Case"v"c
ReturnTrue
CaseElse
ReturnFalse
EndSelect
EndFunction
转换
PrivateSharedFunctionConversion(ByValpyStrAsString,_
ByValtoneSiteAsInteger,_
ByValtoneValueAsInteger,_
ByValtoneCharAsChar)AsString
IftoneValue>=1AndtoneValue<=4Then
SelectCasetoneChar
Case"a"
pyStr=pyStr.Replace(toneChar,a(toneValue).Chars(0))
Case"o"
pyStr=pyStr.Replace(toneChar,o(toneValue).Chars(0))
Case"e"
pyStr=pyStr.Replace(toneChar,e(toneValue).Chars(0))
Case"i"
pyStr=pyStr.Replace(toneChar,i(toneValue).Chars(0))
Case"u"
pyStr=pyStr.Replace(toneChar,u(toneValue).Chars(0))
Case"v"
pyStr=pyStr.Replace(toneChar,v(toneValue).Chars(0))
EndSelect
pyStr=pyStr.Replace(toneValue.ToString,"")
ReturnpyStr
EndIf
EndFunction
#EndRegion
#Region"由汉字到拼音"
PublicSharedFunctionGetHzToPy(ByValHzStrAsString,_
OptionalByValToneValueAsInteger=0,_
OptionalByValIsCompAsBoolean=False)AsString
ByValtoneValueAsInteger,_
IfHzStr.Length=0ThenExitFunction
IfPyList.Count=0ThenLoadPyChars()
mIsCompelled=IsComp
IfmIsCompelledThen
Else
DimtmpStrAsString=""
DimiAsInteger
DimnumAsInteger
Fori=1ToHzStr.Length
num=Asc(HzStr)
Debug.WriteLine(num.ToString)
tmpStr=GetPyChars(num)
tmpStr=GetPyToPy(tmpStr&ToneValue)
ReturntmpStr
Next
EndIf
EndFunction
PrivateSharedFunctionGetPyChars(ByValnumAsInteger)AsString
Ifnum>0Andnum<160Then
ReturnChr(num)
Else
Ifnum<-20319Ornum>-10247Then
Return""
Else
Dimi,valueAsInteger
Fori=PyList.Count-1To0Step-1
IfPyList.GetByIndex(i)<=numThenExitFor
Next
value=CType(PyList.GetByIndex(i),Integer)
ReturnPyList.GetKey(i).ToString
EndIf
EndIf
EndFunction
#EndRegion
EndClassC#中有两处地方用到new关键字,第一处也是最常见的一处是用在调用构造函数的时候,这种情况也是大家见的最多的一种。另一处是用在派生类中,作用有隐藏成员,切断继承关系等,相信第二处的用法大家明显要比第一处生疏。 |