|
-
Jun 20th, 2005, 07:18 PM
#1
Thread Starter
New Member
[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.
-
Jun 20th, 2005, 07:24 PM
#2
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
-
Jun 20th, 2005, 07:24 PM
#3
Addicted Member
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
-
Jun 20th, 2005, 07:26 PM
#4
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
-
Jun 20th, 2005, 07:28 PM
#5
Thread Starter
New Member
Re: Concatenation Problem
thanks a bunch guys! been struggling on such an easy task
-
Jun 20th, 2005, 08:43 PM
#6
Thread Starter
New Member
Re: Concatenation Problem
-
Jun 20th, 2005, 08:58 PM
#7
Re: Concatenation Problem
-
Jun 20th, 2005, 09:02 PM
#8
Thread Starter
New Member
Re: Concatenation Problem
i added in an edit to the first post, probly should of put the problem in the bump sorry
-
Jun 20th, 2005, 09:04 PM
#9
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.
-
Jun 20th, 2005, 09:25 PM
#10
Thread Starter
New Member
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
-
Jun 20th, 2005, 09:38 PM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|