Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:46:02+00:00 2026-06-17T12:46:02+00:00

This question originates from here . I tried this statement in VS to see

  • 0

This question originates from here. I tried this statement in VS to see what happens:

Len(Name <= 3)

According to this answer and also this one, Boolean should consume 4 bytes. According to MSDN, Len Function in VB

Returns an integer containing either the number of characters in a
string or the nominal number of bytes required to store a variable.

Name <= 3 should convert 3 to String and perform string comparison, returning a boolean value, so Len should evaluate number of bytes in it, which should be 4. For some reason, above code returns 2, regardless of the second parameter. In other words, Len(True) also returns 2. Tried for different platform targets (32 and 64) – same thing.

Why does Len(Boolean) return 2 instead of 4?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:46:03+00:00Added an answer on June 17, 2026 at 12:46 pm

    With user-defined types and Object variables, the Len function returns the size as it will be written to the file by the FilePut function. If an Object contains a String, it will return the length of the string. If an Object contains any other type, it will return the size of the object as it will be written to the file by the FilePut function.

    Len() is a legacy function, it should only be used in code that was ported from previous generation Visual Basic projects. Where it would typically appear in code that involved binary serialization of VB values. Sizes of basic types were different in those old versions. Integer was 16 bits for example, explaining the great number of bad pinvoke declarations you find in the web that use Long. And Boolean was a VARIANT_BOOL under the hood, a 16-bit value. Furthermore quirky by having its True value convert to -1 instead 1.

    Clearly adopting the .NET sizes would have been a heavily breaking change to a lot of data that exists in files written by a VB6 program. Or binary data sent across a TCP connection. Etcetera. Accordingly, the Len() function returns the legacy sizes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question originates from this question, where one of the comments suggests that a
This question originates from a discussion on whether to use SQL ranking functionality or
Also can you please answer this question? how do I get co-ordinates of selected
This question is similar in concept to this one , except I see I
This originates from my original question . I'm expanding on it. Html select options
This question is related to another question I wrote: Trouble using DOTNET from PHP.
The question originated from here: http://www.java.net/forum/topic/glassfish/glassfish/configuring-glassfish-logging-format - without an answer. The default GlassFish 3
This question is a part of my original post here Get Data Into Extjs
I got this question from this discussion . A method call like object.m does
I don't know if my wording for this question may be off, but here's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.