Results 1 to 11 of 11

Thread: [RESOLVED] Concatenation Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    5

    Resolved [RESOLVED] Concatenation Problem

    [RESOLVED] my problem is that im trying to get the lblWord to display "*********"
    all the variables are dimmed appropiately and are working, i can set strNewWord = "*" and then lblWord will display "*" but the concatenation just doesnt seem to work
    if theres any other info you guys need just ask, im totally lost
    *EDIT* this segment was solved using the line
    strNewWord = String(Len(strWord), "*")

    however i need this part in another part of the program and im wondering, is there any reason for the line
    strNewWord = strNewWord & strWordAst(bytI)
    to not work? i have ALL variables declared and they all can be assigned values and i have even tested strNewWord, but this one line just doesnt seem to work


    strWord = "Microsoft"
    bytLength = Len(strWord)
    For bytI = 1 To bytLength
    strWordAst(bytI) = "*"
    strNewWord = strNewWord & strWordAst(bytI)
    Next bytI
    lblWord.Caption = strNewWord
    Last edited by benjiman; Jun 20th, 2005 at 09:25 PM.

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Concatenation Problem

    It works, but ALWAYS declare your variables.

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim strWordAst(100) As String
    3.     Dim strWord As String
    4.     Dim bytLength As Integer
    5.    
    6.     strWord = "Microsoft"
    7.     bytLength = Len(strWord)
    8.    
    9.     For bytI = 1 To bytLength
    10.         strWordAst(bytI) = "*"
    11.         strNewWord = strNewWord & strWordAst(bytI)
    12.     Next bytI
    13.     lblWord.Caption = strNewWord
    14. End Sub

  3. #3
    Addicted Member
    Join Date
    May 2005
    Posts
    168

    Re: Concatenation Problem

    Hi,

    If all you are trying to do is replace each character with an asterisk you cna use:

    VB Code:
    1. Dim strWord As String, strNewWord As String
    2.    
    3. strWord = "Microsoft"
    4. strNewWord = String$(Len(strWord), "*")
    5. lblWord.Caption = strNewWord

    Have a good one!
    BK

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Concatenation Problem

    A simpler way of doing what you want:

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim strA As String
    3.     Dim strB As String
    4.    
    5.     strA = "Microsoft"
    6.     strB = String(Len(strA), "*")
    7.    
    8.     MsgBox strB
    9. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    5

    Re: Concatenation Problem

    thanks a bunch guys! been struggling on such an easy task

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    5

    Re: Concatenation Problem

    bump

  7. #7
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Concatenation Problem

    What's the bump for?

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    5

    Re: Concatenation Problem

    i added in an edit to the first post, probly should of put the problem in the bump sorry

  9. #9
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Concatenation Problem

    Try the code from my first reply. I tested it and it works.
    If you still have problems, set a break point on the first line, and use F8 to step through the code line by line so you can check the values of the variables.

  10. #10

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    5

    Re: Concatenation Problem

    it seems using a fixed string length instead of a variable string length for some reason screwed up strNewWord, thx for the tip on debugging, im fairly new to programming

  11. #11
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: [RESOLVED] Concatenation Problem

    No problem

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