My first question was answered so quickly that I thought i’d ask another question! 🙂
It’s probably really simple for you guys, but I can’t seem to get it.
I’m trying to convert a simple integer array to a string array because, with the problem i have, it easy to crossover a string rather than a int array (or so I think!)
But here is the code so far:
Dim Parent1s() As String
For i = 1 To ChromoLength.Value
y = y + Val(MyArray(rnd2, i))
q = Val(MyArray(rnd2, i))
Parents1(i) = q
Next i
For i = 0 To ChromoLength.Value
Parent1s(i) = Val(Parents1(i))
Next i
'Cells(8, 1) = Parent1s
I can’t sem to get Parent1s to produce a string, keep getting a mismatch error
Everything else has been dim’d correctly cause the rest of the code works when i hash out the parent1s statements.
Thanks guys!
You can use the
CStr()function to convert values toStrings.However, I suspect your problems may be because you have not used
Option Explicitand are running into problems with variables being namedParent1sas well asParents1. If you intended for these to be so similar I would strongly encourage a better naming convention. Otherwise, the following seems like it should work: