Results 1 to 3 of 3

Thread: string indexing replacement function for VB 6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2007
    Location
    Dublin, Ireland
    Posts
    120

    string indexing replacement function for VB 6

    Hi,
    Does anyone know how to create a string and place two strings into it so they are formatted correctly. Trying to create a drop-down menu in VB6 and this is the only aspect I have difficulty with:
    Have something like this using the replace function:
    totalProjectDescription = "/// \\\"
    changeProjectDescription = Replace(totalProjectDescription, "///", projectIVMNumber, 1, 1, vbTextCompare)
    changeProjectDescription = Replace(changeProjectDescription, "\\\", projectDescription, 1, 1, vbTextCompare)
    Unfortunately getting a result like this in my drop-down with incorrect spacing and unfortunately having difficulty showing this in my question (spacing removed)
    I306 Millenium (spacing okay)
    I307 Happy (2 characters onwards)
    I324 Unhappy (4 characters onwards)
    Anyone know how I can get it like:
    I306 Millenium (correct spacing)
    I307 Happy (correct spacing)
    I324 Unhappy (correct spacing)
    Is there an index replacement function in VB6?
    Thanks.

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: string indexing replacement function for VB 6

    Try using just this line (don't use Replace)
    VB Code:
    1. changeProjectDescription  = Trim$(projectIVMNumber) & " " & Trim$(projectDescription)

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: string indexing replacement function for VB 6

    don't know why you are doing it that way, how about
    VB Code:
    1. changeProjectDescription = Replace(totalProjectDescription, "/// \\\", projectIVMNumber & " " & projectDescription, 1, 1, vbTextCompare)
    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

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