dcsimg
Results 1 to 7 of 7

Thread: [RESOLVED] add text to end of text

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    6

    Resolved [RESOLVED] add text to end of text

    hi
    i want to add text to end of text ... i have numbers like
    123
    456
    756
    788
    788

    all i want is add to the end of line "test" .. and should be like this
    123test
    456test
    756test
    788test
    788test

    any help please :\

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,677

    Re: add text to end of text

    to concatenate 2 or more strings, use & like

    Code:
    msgbox "123" & "test"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    6

    Re: add text to end of text

    hi westconn1 thank you
    but i want add "test" to the all lines

  4. #4
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Re: add text to end of text

    Quote Originally Posted by jone View Post
    hi
    i want to add text to end of text ... i have numbers like
    123
    456
    756
    788
    788
    any help please
    so you 'have' those numbers, OK
    what you should show is: how you 'generate' or 'get' those numbers
    show the code that generates (creates) those numbers
    do not put off till tomorrow what you can put off forever

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,677

    Re: add text to end of text

    if you have all the numbers in an array you can loop through the array like

    Code:
    for i = 0 to ubound(myarr)
      myarr(i) = myarr(i) & "test"
    next
    but you have not given any indication where the numbers are contained

    if the numbers are printed on a form, you would have to get the position of each number then print the word test to the form at the end of the number, it may be difficult to get the correct position
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,948

    Re: add text to end of text

    Code:
    
    Option Explicit
    
    Private Sub Form_Load()
    
        ' Initialize the string you say you have.
        Dim s As String
        s = "123" & vbCrLf & _
            "456" & vbCrLf & _
            "756" & vbCrLf & _
            "788" & vbCrLf & _
            "788" & vbCrLf
    
        ' Make an array of it.
        Dim a() As String
        a = Split(s, vbCrLf)
    
    
        ' Add "test".
        Dim i As Long
        For i = LBound(a) To UBound(a)
            If Len(a(i)) Then a(i) = a(i) & "test"
        Next i
    
    
        ' Re-combine.
        s = Join(a, vbCrLf)
    
    
        ' Show results.
        Debug.Print s
    
    
    
        Stop
        Unload Me
    
    
    
    End Sub
    
    
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    6

    Re: add text to end of text

    thank you ♥

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width