Does String Datatype in VBA hold more than 255 characters?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sirdevo
    New Member
    • Nov 2009
    • 9

    #1

    Does String Datatype in VBA hold more than 255 characters?

    I'm trying to use a SQL statement that is longer than 255 characters in Access VBA 2007. When I look at the local variable it cuts the rest of the string variable off. Code I used was this in VBA.

    dim myStr as String

    myStr = "String Holds more than 255 characters"

    I've tried using a couple of differnt strings to see if my syntax of the string in the variable was wrong but it still cuts off at 255 characters.

    Thank you,
    Devo
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    How are you examining the contents of the string?

    Comment

    • sirdevo
      New Member
      • Nov 2009
      • 9

      #3
      Creating a breakpoint and then checking the locals screen.

      Devo

      Comment

      • ChipR
        Recognized Expert Top Contributor
        • Jul 2008
        • 1289

        #4
        It must be a limitation of the editor. Here's a simple test:
        After you declare your long string,
        Code:
        MsgBox Len(myStr)

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          Also,
          Code:
          Debug.Print myStr

          Comment

          • sirdevo
            New Member
            • Nov 2009
            • 9

            #6
            Thanks Chip,

            The whole string does come through in the msgbox, so it must be a limitation of the editor. I was wanting to check it since it was an UPDATE statement and would have hated to change the whole table with a bad statement. It showed the whole message when I put the String into a messagebox.

            Thank you again,
            Devo

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              Straight from the (Access Help) horse's mouth:

              String Data Type

              There are two kinds of strings: variable-length and fixed-length strings.

              A variable-length string can contain up to approximately 2 billion (2^31) characters.

              A fixed-length string can contain 1 to approximately 64K (2^16) characters.

              Welcome to Bytes!

              Linq ;0)>

              Comment

              • keirnus
                New Member
                • Aug 2008
                • 48

                #8
                Just what I was looking for.

                missinglinq never miss :)

                kudos! (^_^)/

                Comment

                Working...