JMK
JMK

Reputation: 28059

How do I access the individual characters of a string in VB6

Consider the following VB code:

    Dim fooBar As String
    fooBar = "Foo Bar"

    Dim q As String
    q = fooBar(0)

In VB.Net, this compiles and my q string variable is set to the letter "F", however in VB6 I get a compile error, as the compiler expects an array.

I am in a scenario in VB6 where it would be really useful to be able to treat a string this way, as in access the individual characters via an indexer or something similar.

How do I access the individual characters of a string in VB6?

Thankyou

Upvotes: 5

Views: 8143

Answers (1)

Kendall Frey
Kendall Frey

Reputation: 44316

Use Mid:

q = Mid(fooBar, 1, 1)

Upvotes: 14

Related Questions