JimDel
JimDel

Reputation: 4359

How do I replace the last character in a string with VB6?

How do I replace the last character in a string with VB6? I've got the syntax

Replace$(expression, find, replacewith[, start[, count[, compare]]])

but I can't seem to find the right use of it. I've got something like

iLength = Len(sBuild)
sBuild = Replace(sBuild, "^", "ú", iLength, 1)

This isn't working but I can't seem to find any examples online.

Thanks!

Upvotes: 6

Views: 5333

Answers (2)

Deanna
Deanna

Reputation: 24273

Another method is to use the Mid() keyword:

Mid$(sBuild, Len(sBuild), 1) = "ú"

This also has the advantage of not doing string concatenation/memory reallocation.

Upvotes: 10

chris neilsen
chris neilsen

Reputation: 53127

Try

sBuild = Left$(sBuild, iLength - 1) & "ú"

Upvotes: 4

Related Questions