Using a custom function to get the first letter of Chinese characters

Source: Internet
Author: User
Tags end
Using a custom function to get the first letter of Chinese characters

<script language=vbscript>
<!--
''''''''''''''''''''''
' Provider: Little White
' Contact Method:
' E-mail:xiaobai@17560.net
' You are welcome to test
' For the problems that CHENJF netizens found
' Little White made a change
In addition, to Andrew Netizen's reply is: This function can only obtain now ...? Oh
' If there is a wrong place, please bring it up or help perfect it.
' Thank
''''''''''''''''''''''''''''''
function Getpychar (char)
TMP=65536+ASC (char)
if (tmp>=45217 and tmp<=45252) then
Getpychar= "A"
ElseIf (tmp>=45253 and tmp<=45760) then
Getpychar= "B"
ElseIf (tmp>=45761 and tmp<=46317) then
Getpychar= "C"
ElseIf (tmp>=46318 and tmp<=46825) then
Getpychar= "D"
ElseIf (tmp>=46826 and tmp<=47009) then
Getpychar= "E"
ElseIf (tmp>=47010 and tmp<=47296) then
Getpychar= "F"
ElseIf (tmp>=47297 and tmp<=47613) then
Getpychar= "G"
ElseIf (tmp>=47614 and tmp<=48118) then
Getpychar= "H"
ElseIf (tmp>=48119 and tmp<=49061) then
Getpychar= "J"
ElseIf (tmp>=49062 and tmp<=49323) then
Getpychar= "K"
ElseIf (tmp>=49324 and tmp<=49895) then
Getpychar= "L"
ElseIf (tmp>=49896 and tmp<=50370) then
Getpychar= "M"
ElseIf (tmp>=50371 and tmp<=50613) then
Getpychar= "N"
ElseIf (tmp>=50614 and tmp<=50621) then
Getpychar= "O"
ElseIf (tmp>=50622 and tmp<=50905) then
Getpychar= "P"
ElseIf (tmp>=50906 and tmp<=51386) then
Getpychar= "Q"
ElseIf (tmp>=51387 and tmp<=51445) then
Getpychar= "R"
ElseIf (tmp>=51446 and tmp<=52217) then
Getpychar= "S"
ElseIf (tmp>=52218 and tmp<=52697) then
Getpychar= "T"
ElseIf (tmp>=52698 and tmp<=52979) then
Getpychar= "W"
ElseIf (tmp>=52980 and tmp<=53640) then
Getpychar= "X"
ElseIf (tmp>=53689 and tmp<=54480) then
Getpychar= "Y"
ElseIf (tmp>=54481 and tmp<=62289) then
Getpychar= "Z"
Else ' If it is not Chinese, it is not processed
Getpychar=char
End If
End Function

function Getpy (str)
For I=1 to Len (str)
Getpy=getpy&getpychar (Mid (str,i,1))
Next
End Function
d= "Just check"
MsgBox Getpy (d)
-->
</SCRIPT>



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.