E
EagleOne
2003, 2007
Wish to capture multi-position/values of " ~ " in MainS (via Range("A1".Value = Position(i).Value )
MainS = "~972552~2~~3" (which is the OrigStr below, with all operators replaced with "~"
OrigStr = "(972552/2)*3"
Therefore the Position(i) array manually would be:
Option Base 1
Dim Position(4)
Position(1) "("
Position(2) "/"
Position(3) ")"
Position(4) "*"
Requesting help to finish the code below to pragmatically handle the Array.
Sub OperatorPositionsValueInStr()
Dim MainS As String
Dim SubS As String
Dim i As Long
Dim k As Long
OrigStr = "(972552/2)*3"
'MainS = "~972552~2~~3" (memo only)
SubS = "~"
'Obtain number of "~" in MainS
For i = 1 To Len(MainS)
If Mid(MainS, i, Len(SubS)) = SubS Then
k = k + 1
End If
Next i
Dim Positions(k)
For i = 1 To k
'How do I code so that each Position(i) in MainS is saved
' separately in the Array Position(i)?
'
' "????" is an increasing number to the full Len(MainS)
'
Positions(i) = InStr("????", MainS, "~", vbTextCompare)
Next i
'Output example:
Range("A" & i).Value = Position(i).Value
End Sub
*******************************
My brain goes into complete fart-mode when it comes to Arrays.
Especially multiple demensional which may seem to be appropriate
in this case i.e. Position(Position in MainS, Value in MainS)
Any thoughts greatly appreciated
EagleOne
Wish to capture multi-position/values of " ~ " in MainS (via Range("A1".Value = Position(i).Value )
MainS = "~972552~2~~3" (which is the OrigStr below, with all operators replaced with "~"
OrigStr = "(972552/2)*3"
Therefore the Position(i) array manually would be:
Option Base 1
Dim Position(4)
Position(1) "("
Position(2) "/"
Position(3) ")"
Position(4) "*"
Requesting help to finish the code below to pragmatically handle the Array.
Sub OperatorPositionsValueInStr()
Dim MainS As String
Dim SubS As String
Dim i As Long
Dim k As Long
OrigStr = "(972552/2)*3"
'MainS = "~972552~2~~3" (memo only)
SubS = "~"
'Obtain number of "~" in MainS
For i = 1 To Len(MainS)
If Mid(MainS, i, Len(SubS)) = SubS Then
k = k + 1
End If
Next i
Dim Positions(k)
For i = 1 To k
'How do I code so that each Position(i) in MainS is saved
' separately in the Array Position(i)?
'
' "????" is an increasing number to the full Len(MainS)
'
Positions(i) = InStr("????", MainS, "~", vbTextCompare)
Next i
'Output example:
Range("A" & i).Value = Position(i).Value
End Sub
*******************************
My brain goes into complete fart-mode when it comes to Arrays.
Especially multiple demensional which may seem to be appropriate
in this case i.e. Position(Position in MainS, Value in MainS)
Any thoughts greatly appreciated
EagleOne