Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

string

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

like image 401
JMK Avatar asked Aug 16 '12 15:08

JMK


1 Answers

Use Mid:

q = Mid(fooBar, 1, 1)
like image 52
Kendall Frey Avatar answered Sep 28 '22 01:09

Kendall Frey