因为手机短消息的发送是以PDU串的形式发送出去的,中文字符以Unicode码来表示,所以在发送中文短消息之前必须首先将中文字符转换为Unicode码,下面的函数将实现这个功能。这个函数主要应用到VB自带的一个格式转换函数:ChrW()将中文转换为Unicode码。 

  Public Function chg(rmsg As String) As String
  Dim tep As String
  Dim temp As String
  Dim i As Integer
  Dim b As Integer
  tep = rmsg
  i = Len(tep)
  b = i / 4
  If i = b * 4 Then
   b = b - 1
   tep = Left(tep, b * 4)
  Else
   tep = Left(tep, b * 4)
  End If
  chg = ""
  For i = 1 To b
   temp = "&H" & Mid(tep, (i - 1) * 4 + 1, 4)
   chg = chg & ChrW(CInt(Val(temp)))
  Next i
  End Function