请问各位高手:怎样用vb代码实现 得到一个汉字的拼音首字母的大写,能实现的而且是尽量简洁的.
                
                             [email protected]

解决方案 »

  1.   

    Private Sub Command1_Click()
       MsgBox Get_("我们")  '输出"WM"
       MsgBox GetChar("我们")   '输出"W"
    End SubPublic Function GetChar(char)
       tmp = 65536 + Asc(char)
       If (tmp >= 45217 And tmp <= 45252) Then
             GetChar = "A"
          ElseIf (tmp >= 45253 And tmp <= 45760) Then
             GetChar = "B"
          ElseIf (tmp >= 45761 And tmp <= 46317) Then
             GetChar = "C"
          ElseIf (tmp >= 46318 And tmp <= 46825) Then
             GetChar = "D"
          ElseIf (tmp >= 46826 And tmp <= 47009) Then
             GetChar = "E"
          ElseIf (tmp >= 47010 And tmp <= 47296) Then
             GetChar = "F"
          ElseIf (tmp >= 47297 And tmp <= 47613) Then
             GetChar = "G"
          ElseIf (tmp >= 47614 And tmp <= 48118) Then
             GetChar = "H"
          ElseIf (tmp >= 48119 And tmp <= 49061) Then
             GetChar = "J"
          ElseIf (tmp >= 49062 And tmp <= 49323) Then
             GetChar = "K"
          ElseIf (tmp >= 49324 And tmp <= 49895) Then
             GetChar = "L"
          ElseIf (tmp >= 49896 And tmp <= 50370) Then
             GetChar = "M"
          ElseIf (tmp >= 50371 And tmp <= 50613) Then
             GetChar = "N"
          ElseIf (tmp >= 50614 And tmp <= 50621) Then
             GetChar = "O"
          ElseIf (tmp >= 50622 And tmp <= 50905) Then
             GetChar = "P"
          ElseIf (tmp >= 50906 And tmp <= 51386) Then
             GetChar = "Q"
          ElseIf (tmp >= 51387 And tmp <= 51445) Then
             GetChar = "R"
          ElseIf (tmp >= 51446 And tmp <= 52217) Then
             GetChar = "S"
          ElseIf (tmp >= 52218 And tmp <= 52697) Then
             GetChar = "T"
          ElseIf (tmp >= 52698 And tmp <= 52979) Then
             GetChar = "W"
          ElseIf (tmp >= 52980 And tmp <= 53640) Then
             GetChar = "X"
          ElseIf (tmp >= 53689 And tmp <= 54480) Then
             GetChar = "Y"
          ElseIf (tmp >= 54481 And tmp <= 62289) Then
             GetChar = "Z"
          Else '如果不是中文,则不处理
             GetChar = char
       End If
    End Function
    Function Get_(str)
       For i = 1 To Len(str)
          Get_ = Get_ & GetChar(Mid(str, i, 1))
       Next i
    End Function
      

  2.   

    ro StarRib(StarRib):
       我想知道,您是怎么知道汉字的字符代码的?
      比如,“擦”的代码。我看了你的程序是:45761,您是怎么知道擦的代码就刚好是汉字拼音b字母后边的呢?
    谢谢!
    向你学习!
      

  3.   

    二楼的办法仅对GB2312基本字库有效,类似“鑫鳓”这些字是无法奏效的。http://smallfairy.51.net/KiteGirl/PYGet.htm
    这个网页里的VBS程序是个例子,稍微改一下就可以了。想准确得到所有GBK编码的读音,还是需要查表。你可以这样解决:1、在GB2312基本编码范围内的,以二楼的办法取首字母。2、不在GB2312基本编码范围内的,以查表法解决。
      

  4.   

    KiteGirl(小仙妹) 说的对,大家可以去这里了解一些编码信息:http://www.uighurlinux.org/
    http://www.founder.com.cn/support/font/encode.htmTO: broown(broown) 我这个编码表是很早以前在一个论坛里得到的.呵呵.