Link to home
Start Free TrialLog in
Avatar of llcoolmel
llcoolmel

asked on

Insert Text

hi, i am trying to convert a group of numbers to follow a certain equation.

first i begin with the group of numbers, for example:
15-26 2-3 5-12 4 9 13 4 4 0 2 3 35

then i (would like to learn how to)convert this group of numbers into this:
15-26 0*2-0*3 5-12 0*4 0*9 13 4 0*4 0 -1*2 3 35

basically, what i'm doing is cancelling out the 2nd cluster of numbers (2-3), the 4th cluster (4), the 5th cluster (9) and changing 10th cluster (2) into a negative number.  the problem is i have absolutely no idea how to do this programmatically.

so i'm asking for the specific code on how to do this.  if i recieve the full code that will work out perfectly and exactly the way i like it, i will give you 450 PTS!!!!
Avatar of roverm
roverm
Flag of Netherlands image

Look for spaces using the instr function:

Private Sub Command1_Click()
Dim strDummy As String
Dim strResult As String
Dim i As Integer
Dim j As Integer
Dim last As Integer
'Text1 = a textbox containing your string

    Text1 = " " & Text1 'create start point
    strResult = ""
    last = 1
    Do
        i = InStr(last, Text1, " ")
        If i > 0 Then 'space found!
            strDummy = Mid(Text1, i + 1) 'get it starting from the space+1
            j = InStr(1, strDummy, " ") 'find end
            If j > 0 Then strDummy = Left(strDummy, j - 1)
            'now convert the result string
            'you have to write that code, since i don't know when to change into what!
            'the string to be converted is in strDummy so change that!
            'after strDummy is converted:
            strResult = strResult & strDummy & " "
            If j = 0 Then Exit Do
            last = j + last
        Else
            Exit Do
        End If
    Loop
    Label1.Caption = strResult

End Sub

Good luck!

D'Mzzl!
RoverM
Text can be manipulated in VB but I don't understand the reason for what you want to do.  How do you decide which bits get cancelled out?  Are you trying to evaluate mathematical equations?  

We need some sort of rules behind what you want to do.

deighton: that's why I described in my code:
            'now convert the result string
            'you have to write that code, since i don't know when to change into what!
            'the string to be converted is in strDummy so change that!
            'after strDummy is converted:

But the code works perfectly!

Any code works perfectly if nobody knows what its meant to do.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial