Results 1 to 5 of 5

Thread: How can add some values from one String to another

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Germany
    Posts
    15

    Question

    Hy guys,

    I need some help with strings. The two strings show like this.

    1. -Value1;-Value2;-Value3
    2. -Value1;-Value2;-Value3;Value4

    I would like to add all values with "-" in one string.

    Thanks for help!

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    what is your code and where are you loading the strings
    is the string an array with ; as a delimiter
    or do you have a file with a bunch of numbers
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Germany
    Posts
    15
    Sorry

    Both strings are arrays an the ; is the delimiter
    the second string is comeing from a file
    the first from the registry

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    For Each Item in arrayname
     singlestring=singlestring & "-" & Item
    next Item
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
    Dim Sfile As String, var1 As String
    Dim sResult As Variant
    
    'Sfile = "yourpath/yourfile/ext"
    var1 = "-4;-4;-4;6;6"
    'Open Sfile For Input As intNum
        'read the complete file into a string variable
        'var1 = StrConv(InputB(LOF(intNum), intNum), vbUnicode)
       ' Close intNum
        Dim i As Integer
        'use the split function to split the string
        'into sections using the ; as the split pos
        sResult = Split(var1, ";")
        'read the split into the public array
        
        Dim myArr() As Integer
        
        For i = 0 To UBound(sResult)
        ReDim Preserve myArr(i)
           myArr(i) = Trim(sResult(i))
          Next i
          For i = 1 To UBound(myArr)
          If Left(myArr(i), 1) = "-" Then
             myArr(i) = myArr(i) + myArr(i - 1)
          End If
        
        Next i
        
        'display
        For i = 1 To UBound(myArr)
          MsgBox myArr(i)
            Next i
            
        
      ' then rejoin the array...and put it back or whatever you
       'plan on doing
        
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width