Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • "I am new to vb6..." No one should be new to VB6. :-) It's a dead technology. (VBA is still active, though.) If you're new to programming, FWIW I suggest studying something more modern, like VB.Net. Commented Oct 15, 2020 at 10:19
  • What line is the error complaining about? My VB6 is very rusty, but I suspect you want to compare the result of InStr with something, e.g. If InStr(sBadChar, Mid(MyStr, i, 1) > 0. But it might also be complaining about Mid(MyStr, i, 1) = "", I don't recall whether that's valid in VB6, but I suspect not. You probably want MyStr = Left(MyStr, i - 1) & Mid(MyStr, i) Note that you'll also have to handle the fact that i is now too far ahead (because the string got shorter). You could fix that by looping backward rather than forward (For i = Len(MyStr) To 1 Step -1). Commented Oct 15, 2020 at 10:23
  • 1
    @T.J.Crowder, Yes I only have a few months of programming and I prefer java or python but the biggest software we provide is still written in vb6 this is why I said I was new to VB6. we are converting everything to VB.NET :) thanks for your feedback I think Johns answer is working fine for me. Commented Oct 15, 2020 at 12:43
  • 4
    We always forget there is a huge base of VB6 code in production. It's not going away anytime soon, and someone has to maintain it. Commented Oct 15, 2020 at 14:02