Lots of stupid questions lately, but I would appreciate some input on this one.
I've got a string that comes from an INI-file. It looks like Firstname=FIRSTNAME. This is basically an array with loads of these. I want to split these up, but preserve both of them. So, I managed to put Firstname in it's own array and FIRSTNAME in it's own. But then a colleague of mine said "Why don't you just use a multidimensional array instead?". And this got me thinking, putting Firstname in 0 and FIRSTNAME in 1. But how do I do that?
This is my code right now:
For iTeller = 0 To UBound(arrIniName)
If Not arrIniName(iTeller) = "" Then
arrIniName(iTeller) = Split(arrIniName(iTeller), "=")(0)
End If
Next
For iTeller = 0 To UBound(arrIniValue)
If Not arrIniValue(iTeller) = "" Then
arrIniValue(iTeller) = Split(arrIniValue(iTeller), "=")(1)
End If
Next
Both arrIniName and arrIniValues consists of the exact same array to begin with. Which looks like this:
arrIniName(0) "Fistname=FIRSTNAME"
arrIniName(1) "Lastname=LASTNAME"
arrIniName(2) "Initials=INITIALS"
So I basically split each one into their own separate arrays the way I do it now. But putting them in a multi dimensional array would probably be better? Because then I'd have just one array to manage and could also pull that array through a For Each loop.
Edit: I ended up doing it like this, where Values is the array
For Each s In Values
Dim strName, strValue
s = Split(s, "=")
strName = s(0)
strValue = s(1)
'Run function strName, strValue
Next
Scripting.Dictionaryentry. So basically, I just want to dynamically create variables based on what's in the INI file. Later on, I look for bookmarks in the Word template based onFIRSTNAMEand inserts a value into it. I just want it to be dynamic so I only have to update the ini file and insert the bookmark I want, without having to worry about the code behind you see :) Hope that makes sense :p