[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 :eek2:
*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
Re: Concatenation Problem
It works, but ALWAYS declare your variables.
VB Code:
Private Sub Form_Load()
Dim strWordAst(100) As String
Dim strWord As String
Dim bytLength As Integer
strWord = "Microsoft"
bytLength = Len(strWord)
For bytI = 1 To bytLength
strWordAst(bytI) = "*"
strNewWord = strNewWord & strWordAst(bytI)
Next bytI
lblWord.Caption = strNewWord
End Sub
Re: Concatenation Problem
Hi,
If all you are trying to do is replace each character with an asterisk you cna use:
VB Code:
Dim strWord As String, strNewWord As String
strWord = "Microsoft"
strNewWord = String$(Len(strWord), "*")
lblWord.Caption = strNewWord
Have a good one!
BK
Re: Concatenation Problem
A simpler way of doing what you want:
VB Code:
Private Sub Form_Load()
Dim strA As String
Dim strB As String
strA = "Microsoft"
strB = String(Len(strA), "*")
MsgBox strB
End Sub
Re: Concatenation Problem
thanks a bunch guys! been struggling on such an easy task :(
Re: Concatenation Problem
Re: Concatenation Problem
Re: Concatenation Problem
i added in an edit to the first post, probly should of put the problem in the bump sorry
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.
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
Re: [RESOLVED] Concatenation Problem