登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

miaozk2006

点滴积累与收藏:关于技术,关于生活

 
 
 

日志

 
 

VB 获取汉字拼音的首字母  

2013-01-31 11:46:50|  分类: 编程-VB |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Public Function py(mystr As String) As String
If Asc(mystr) < 0 Then
If Asc(Left$(mystr, 1)) < Asc("啊") Then
py = "0"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("啊") And Asc(Left$(mystr, 1)) < Asc("芭") Then
py = "A"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("芭") And Asc(Left$(mystr, 1)) < Asc("擦") Then
py = "B"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("擦") And Asc(Left$(mystr, 1)) < Asc("搭") Then
py = "C"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("搭") And Asc(Left$(mystr, 1)) < Asc("蛾") Then
py = "D"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("蛾") And Asc(Left$(mystr, 1)) < Asc("发") Then
py = "E"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("发") And Asc(Left$(mystr, 1)) < Asc("噶") Then
py = "F"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("噶") And Asc(Left$(mystr, 1)) < Asc("哈") Then
py = "G"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("哈") And Asc(Left$(mystr, 1)) < Asc("击") Then
py = "H"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("击") And Asc(Left$(mystr, 1)) < Asc("喀") Then
py = "J"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("喀") And Asc(Left$(mystr, 1)) < Asc("垃") Then
py = "K"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("垃") And Asc(Left$(mystr, 1)) < Asc("妈") Then
py = "L"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("妈") And Asc(Left$(mystr, 1)) < Asc("拿") Then
py = "M"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("拿") And Asc(Left$(mystr, 1)) < Asc("哦") Then
py = "N"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("哦") And Asc(Left$(mystr, 1)) < Asc("啪") Then
py = "O"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("啪") And Asc(Left$(mystr, 1)) < Asc("期") Then
py = "P"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("期") And Asc(Left$(mystr, 1)) < Asc("然") Then
py = "Q"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("然") And Asc(Left$(mystr, 1)) < Asc("撒") Then
py = "R"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("撒") And Asc(Left$(mystr, 1)) < Asc("塌") Then
py = "S"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("塌") And Asc(Left$(mystr, 1)) < Asc("挖") Then
py = "T"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("挖") And Asc(Left$(mystr, 1)) < Asc("昔") Then
py = "W"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("昔") And Asc(Left$(mystr, 1)) < Asc("压") Then
py = "X"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("压") And Asc(Left$(mystr, 1)) < Asc("匝") Then
py = "Y"
Exit Function
End If
If Asc(Left$(mystr, 1)) >= Asc("匝") Then
py = "Z"
Exit Function
End If
Else
If UCase$(mystr) <= "Z" And UCase$(mystr) >= "A" Then
py = UCase$(Left$(mystr, 1))
Else
py = mystr
End If
End If
End Function
Public Function test(str As String) As String
Dim tmp As String
For i = 1 To Len(str)
tmp = tmp & py(Mid$(str, i, 1))
Next i
test = tmp
End Function

Private Sub Form_Load()
MsgBox test("中国人") '结果: ZGR
End Sub

摘自:网络整理


VB相关


VB 读写TXT文本文件函数

VB 提取TextBox 文本框中指定一行字符串

VB 获取汉字拼音的首字母

VB 汉字字符串转换成拼音

VB判断指定名字的进程是否存在函数

VB 两种方法实现热键

VB 使用SendMessage枚举文件与目录

VB 二进制数组与十六进制字符串相互转换

VB 二进制数据读写实例

VB 进制转换大全(十进制、十六进制、八进制、二进制、二进制流)互转

VB 判断是否文本文件

VB 读取UTF-8编码文件函数

VB 按指定编码格式写入文本文件

VB UTF-8 URL编码函数

VB 实现UTF-8 GB2312互转

VB 设置ListView中指定一行的背景颜色

VB SendMessage向其他程序窗口发送字符串消息实例

VB Listview导出到CSV文件函数

vb卸载所有窗体

VBNull, Empty, Nothing, and vbNullString的区别

利用API函数计算程序运行时间VB

获取快捷方式原文件路径vb路径

利用VB函数Dir()实现递归搜索目录

VB数组的清除和重新定义

RtlAdjustPrivilege来调整进程权限(VB6.0代码)

获取对象的接口信息(方法/属性/事件)(VB6代码)

VB6中给数组赋值的限制

[vb]一些窗口消息的详解

VB直接播放EXE文件中的声音文件

VB中利用CopyMemory使用指针

VB读写注册表的三种方法

[VB]SaveSetting 语句 和 DeleteSetting 语句

VB APP对象属性一览表 + 灵活使用VBAPP对象

[vb]SendMessageA函数

使用VB绘制抛物线动画曲线

关于vb中的容器

[vb]利用WScript.Shell对象隐藏cmd命令行运行

浅析VB For Each.Next语句

VB中窗体模块、标准模块、类模块的区别

引用 VB类模块

VB中什么是类,类模块有什么作用

VB SendKeys 语句

VB 全局热键

VB轻松调用其他程序

vb读取txt文件到textbox

如何去优化你的VB程序3

如何去优化你的VB程序2

如何去优化你的VB程序1

[VB]在状态栏中显示帮助信息

[VB]把屏幕保存为图像

Mp3Play.ocx控件让音乐之声响起来


更多精彩>>>
  评论这张
 
阅读(1611)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018