这个问题我也想知道,ASC(CHR(254))返回0,怎么才能返回254???

解决方案 »

  1.   

    我只知道转换成16进制的函数是:hex
      

  2.   

    试试以下函数:
    Public Function ASCii2Binary(strInput As String) As String  Dim strMid As String
      Dim Number As Integer
      Dim Counter As Integer
      Dim BinaryArray(1 To 8) As Integer
      Dim Result As String    On Error GoTo HandleError
        BinaryArray(1) = 1
        BinaryArray(2) = 2
        BinaryArray(3) = 4
        BinaryArray(4) = 8
        BinaryArray(5) = 16
        BinaryArray(6) = 32
        BinaryArray(7) = 64
        BinaryArray(8) = 128
        strMid = strInput
        Do Until strMid = ""
            Number = Asc(Right$(strMid, 1))
            For Counter = 1 To 8
                If Number And BinaryArray(Counter) Then
                    Result = "1" & Result
                  Else
                    Result = "0" & Result
                End If
            Next Counter
            strMid = Mid$(strMid, 1, Len(strMid) - 1)
        Loop
        ASCii2Binary = ResultExit FunctionHandleError:
        ASCii2Binary = "Pls contact me to report this bug!"
        ErrorOccurred = TrueEnd Function调用很方便:
      z = ASCii2Binary(Chr(4))
     z就会等于00000100了
       也可以输入"hello"这样的字符串,试试吧。to c2000:
     chr(254)返回的会是0,应该从127往上的是扩展ascii码,chr不支持。
      

  3.   

    VB有自带的函数
    如ASCB
    其实VB对字符串处理的函数有三套
    如Asc就有Asc,AscB,AscW
    分别用来处理当前操作系统字符集字符,二进制字符,Unicode字符
      

  4.   

    To Latitude(Henry)高手,那么我想请问一下,我从文件里面读取出来的2个字节
    11111110 00000000(十进制为:254 0)
    怎么才能还原为十进制的254?