Riaan
Riaan

Reputation: 3542

VBA String Limit

I've been working in Visual Basic for Applications (VBA) in Microstation V8i SS2, and I'm getting an Overflow error for my String value.

It seems there is a limit in VBA for String values. The limit seems to be 255 characters. Reading up on it, a lot of sources says it can support up to 2 billion characters. This is not true?

What happens is, I'm using ADO to interact with the database, so I'm building my own SQL INSERT statement inside the VBA. The INSERT statement gets long, like 300+ characters, depending on the 'Comments' column that accepts a multi-line text value.

Anybody have a solution? Should I write my own COM-Addin from a .NET point of view, that gets referenced in the VBA?

MsgBox Len(ssql)

Visual Basic Break

Error handler result

Upvotes: 4

Views: 45987

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300559

VBA strings can be more than 255 chars.

A possible culprit is how the column is declared in your table.... Is the Comments column declared as varchar(255)?

From the help file:

  • 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.

Ref.

Upvotes: 10

Related Questions