VBA String Limit

2019-01-27 06:27发布

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

标签: string vba limit
1条回答
Rolldiameter
2楼-- · 2019-01-27 06:59

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.

查看更多
登录 后发表回答