Results 1 to 2 of 2

Thread: Len and LenB

  1. #1
    Guest

    Question

    Now, in the MSDN, Len is supposed to return the length of the string, and LenB is supposed to return the length of the string in bytes, right?

    But when I ran this:

    Code:
    Private Sub Form_Load()
    
    Dim header As String
    
    header = Space(8)
    MsgBox Len(header)     'an answer of 8
    MsgBox LenB(header)    'answer of 16 (?)
    header = "12345678"
    MsgBox header          'answer "12345678"
    MsgBox Len(header)     '8
    MsgBox LenB(header)    '16
    
    'the file contains the character "1" in it
    MsgBox FileLen("c:\windows\desktop\test.txt")  'answer of 1
    msgbox LenB("1") 'answer of 2!!
    End Sub
    Why does LenB say that "1" uses 2 bytes? It seems that one character always takes up 2 bytes, but FileLen reports a file with the same character as 1 byte. Why is this so?

    Thanks
    Sunny

  2. #2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width