By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Multiply text in a textbox.

P: 3
I was wondering if anyone knew how to multiply text in a textbox according to a specified amount in a textbox, if that doesn't make sense then...

I type in Textbox1: aaa
Then I type in The amount textbox: 10
Then a third textbox would = aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa

Hope it makes sense.

Thanks.

(I tried to google it but I could only find things to multiply numbers)
Jan 1 '08 #1
Share this Question
Share on Google+
4 Replies


100+
P: 274
It's pretty easy to do that:
Suppose first text is in text1.Text and second in text2.Text then

- store text2.Text in an Integer variable : suppose n
- define a string (that will hold string after multiplying text1.Text) : suppose NewStr. Intially store NewStr = ""
- use a loop (maybe for loop) e.g.
Expand|Select|Wrap|Line Numbers
  1. For i = 0 To n-1
  2.   NewStr = NewStr & text1.text
  3. Next i
Finally you will have multiplied value stored in NewStr.
I hope it will help you understand a little bit.

P.S: theScripts Guys mention if I am wrong somewhere

Kind regards
Jan 1 '08 #2

P: 3
Thanks!

This worked great and I have learnt something new.
Jan 1 '08 #3

100+
P: 274
thats good. Keep on doing good work.
Jan 1 '08 #4

Expert 5K+
P: 8,434
Nice one, creative1.

The only thing I think everyone is doing wrong here (and what caused the problems in trying to search for a solution) is using the term "multiply" when what you actually want is to "repeat" or make "copies" of a chunk of text. Searching on "multiply" is naturally going to return mostly mathematical type responses.
Jan 1 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.