Results 1 to 9 of 9

Thread: Adding text to every letter

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Adding text to every letter

    ok i have 6 checkboxes and 4 textboxes basically i enter text in the textboxes example
    Textbox1:Hello
    Textbox2:i
    Textbox3:am
    Textbox4eCo
    each textbox represents a specific symbol what i want to do is add the symbol to every word in the textbox for example if i only checked check box one it would look like
    Hello
    But if i checked two text boxes it will look like
    He$ll$o and so on... i would appreciate the help thank you!

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Adding text to every letter

    Have you tried Replace function?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Adding text to every letter

    Use Mid/Right/Left functions in a loop to get every character of the string.
    Add the custom string to every character inside that loop.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Adding text to every letter

    I'm confused at how checking the second textbox would turn "Hello" into "He$ll$o". Can you explain on that a little more?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Adding text to every letter

    Like this
    VB Code:
    1. Dim sTemp As String
    2.     sTemp = "Hello"
    3.     MsgBox Replace(sTemp, "ll", "$ll$")
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  6. #6
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Adding text to every letter

    for example if i only checked check box one it would look like
    H�e�l�l�o
    But if i checked two text boxes it will look like
    H�e$l�l$o� and so on...
    Sahuja, Looks like he needs character positions too.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Adding text to every letter

    Seems like OP needs to explain it in a better way.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Adding text to every letter

    Each checkbox represents a letter or symbol Could be 'A' or it could be '$' when a checkbox is clicked it enables the letter or symbol and ads it to w/e the text is in the textbox so if the text in the textbox was 'AAA' and Checkbox1 was checked (checkbox1 represents B) then the final text would be ABABAB

  9. #9
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Adding text to every letter

    VB Code:
    1. Private Sub Command1_Click()
    2.     teststring = "AAA"
    3.     For x = 0 To chkchar.Count - 1
    4.         If chkchar(x).Value <> 0 Then
    5.             Select Case x
    6.                 Case 0: strchar = strchar & "A"
    7.                 Case 1: strchar = strchar & "B"
    8.                 Case 2: strchar = strchar & "C"
    9.             End Select
    10.         End If
    11.     Next x
    12.  
    13.     For x = 1 To Len(teststring)
    14.         strfinal = strfinal & Mid$(teststring, x, 1) & strchar
    15.     Next x
    16.  
    17.     MsgBox strfinal
    18. End Sub

    For that example to work, add 3 checkboxes to a form, and make them all in one control array. It works perfect. For you to get this to work, just change teststring to what ever textbox your handling, and make all your checkboxes one control array.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


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