![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 2
Rep Power: 0
![]() |
Help with a counting problem.
I'm very new to programming and this one has stumped me. Im trying to make a counter that will go up by one everytime, but will be put on the end of a value typed into a text box and everytime the program loops it'll go up by one so like this
1st:User 2nd:User1 etc. Any help? |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
Glad you made it AngelX, Oobs will help you, won't you oobs
![]() I'm not quite sure yet how to do it. Sorry.
__________________
And there was much rejoicing... Yay.... |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Well, to append a string to another, use the & operator:
string1 = "Hello " string2 = "World." string3 = string1 & string2 ' string3 = "Hello World." And to increment a counter, declare it as global or static, and increase it on the button click: Private Sub Button1_Click Static count As Integer count = count + 1 End Sub ![]() |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Apr 2005
Posts: 2
Rep Power: 0
![]() |
Ok now it's doing User, User1, User12 o.o
count = count + 1 txtuser.Text = txtuser.Text & count lbluser.Caption = txtuser.Text |
|
|
|
|
|
#5 | |
|
Programmer
Join Date: Feb 2005
Posts: 62
Rep Power: 4
![]() |
Quote:
when you run through the program the first time, you're adding "1" to "user" to produce "user1." when you run through it a second time, you're adding "2" to "user1" to produce "user12." when you run through it a third time, you're adding "3" to "user12" to produce "user123." rather than change txtuser.text AND lbluser.caption, why don't you only change lbluser.caption and leave txtuser.text alone? that way only your output (user1, user2) changes and not your input (user). something like this: count = count + 1 lbluser.Caption = txtuser.Text & count this way, txtuser.text always stays the same, and lbluser.caption constantly changes to reflect the current numerical username. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|