Solved

Insert Text

Posted on 2000-02-22
5
153 Views
Last Modified: 2010-05-02
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!!!!
0
Comment
Question by:llcoolmel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 2549454
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
0
 
LVL 18

Expert Comment

by:deighton
ID: 2549572
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.

0
 
LVL 12

Expert Comment

by:roverm
ID: 2549761
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!

0
 
LVL 18

Expert Comment

by:deighton
ID: 2549838
Any code works perfectly if nobody knows what its meant to do.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 100 total points
ID: 2550267
Private Enum ProcessModeConstants
   Cancel
   Negate
End Enum

Dim sNumbers As String

Private Sub Main()
   
   Debug.Print ProcessNumbers("15-26 2-3 5-12 4 9 13 4 4 0 2 3 35")
   
End Sub

Private Function ProcessNumbers(sList As String) As String

Dim sNumbers() As String

   sNumbers = Split(sList)
   
   Call ProcessCluster(sNumbers(1), Cancel)        '2nd cluster
   Call ProcessCluster(sNumbers(3), Cancel)       '4th cluster
   Call ProcessCluster(sNumbers(4), Cancel)       '5th cluster
   Call ProcessCluster(sNumbers(9), Negate)      '10th cluster
   
   ProcessNumbers = Join(sNumbers)

End Function

Private Sub ProcessCluster(sNumber As String, eMode As ProcessModeConstants)

Dim iDigit As Integer
Dim sDigits() As String
Dim sBuild As String

   sDigits = Split(sNumber, "-")
   
   For iDigit = 0 To UBound(sDigits)
      sBuild = sBuild & IIf(eMode = Cancel, "0*", "-1*") & sDigits(iDigit) & "-"
   Next iDigit
   
   sNumber = Left(sBuild, Len(sBuild) - 1)
   
End Sub

0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 16 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question