kylefoley76
Well-known Member
- Joined
- Mar 1, 2010
- Messages
- 1,553
Take the following string:
<colgroup><col></colgroup><tbody>
</tbody>
What the following code will do is it will put the above into the following array
sent1(1) = ((bHc) ⊻ (bHd))
sent1(2) = ((bHg) → (bHi))
I'm now trying to get the following strings into the sent2 array as so:
sent2(1,2) = (bHc)
sent2(1,2) = (bHd)
sent2(2,1) = (bHg)
sent2(2,2) = (bHi)
What I'm doing wrong I think is I have to reDim Preserve more than one thing but I can't figure out what.
Before I loop through and go to n = 2 the sent2 array is fine, meaning it appears as
sent2(1,2) = (bHc)
sent2(1,2) = (bHd)
But once I go to n = 2, the following happens.
sent2(1,2) = empty
I can then populate the next array as I should, meaning
sent2(2,1) = (bHg)
sent2(2,2) = (bHi)
But sent2(1,2) is still empty.
Sorry, if I'm not being clear but I've got to get back to work, since I'm doing this on the job.
((bHc) ⊻ (bHd)) & ((bHg) → (bHi)) |
<colgroup><col></colgroup><tbody>
</tbody>
What the following code will do is it will put the above into the following array
sent1(1) = ((bHc) ⊻ (bHd))
sent1(2) = ((bHg) → (bHi))
I'm now trying to get the following strings into the sent2 array as so:
sent2(1,2) = (bHc)
sent2(1,2) = (bHd)
sent2(2,1) = (bHg)
sent2(2,2) = (bHi)
What I'm doing wrong I think is I have to reDim Preserve more than one thing but I can't figure out what.
Before I loop through and go to n = 2 the sent2 array is fine, meaning it appears as
sent2(1,2) = (bHc)
sent2(1,2) = (bHd)
But once I go to n = 2, the following happens.
sent2(1,2) = empty
I can then populate the next array as I should, meaning
sent2(2,1) = (bHg)
sent2(2,2) = (bHi)
But sent2(1,2) is still empty.
Sorry, if I'm not being clear but I've got to get back to work, since I'm doing this on the job.
Code:
Dim x As Integer, y As Integer, z As Integer, b As Integer
Dim total As Integer, paren_closure As Integer, marker As Boolean
Dim temp_string As String
For x = InStr(instring, "(") To Len(instring) Step 1
temp_string = Mid(instring, x, 1)
If Mid(instring, x, 1) = "(" Then
If marker = False Then
z = x
marker = True
End If
total = total + 1
ElseIf Mid(instring, x, 1) = ")" Then
total = total - 1
If total = 0 Then
marker = False
b = b + 1
paren_closure = x
ReDim Preserve sent1(b)
sent1(b) = Mid(instring, z, (x - z) + 1)
End If
End If
Next
Dim temp_sent1 As String, n As Integer
total = 0
marker = False
For n = 1 To UBound(sent1)
temp_sent1 = sent1(n)
temp_sent1 = Mid(temp_sent1, 2, Len(temp_sent1) - 2)
b = 0
For x = 1 To Len(temp_sent1)
temp_string = Mid(instring, x, 1)
If Mid(temp_sent1, x, 1) = "(" Then
If marker = False Then
z = x
marker = True
End If
total = total + 1
ElseIf Mid(temp_sent1, x, 1) = ")" Then
total = total - 1
If total = 0 Then
marker = False
b = b + 1
paren_closure = x
ReDim Preserve sent2(1 To UBound(sent1), b)
sent2(n, b) = Mid(temp_sent1, z, (x - z) + 1)
End If
End If
Next
Next