|
-
Oct 24th, 2004, 04:25 AM
#1
Thread Starter
Lively Member
get more than 1 textbox in loop
i want to try something like this
for i = 1 to 10
mes="tekst" + i
msgbox mes.text
next i
but thoes not work
what is the wright code
Last edited by davyquyo; Oct 26th, 2004 at 08:21 AM.
-
Oct 24th, 2004, 04:36 AM
#2
PowerPoster
Do you want to add i (so a number between 1 and 10) to lots of textboxs at once, or are you trying to do something else?
-
Oct 24th, 2004, 04:38 AM
#3
Thread Starter
Lively Member
yes i'm trying to get a lot of textboxes at once
-
Oct 24th, 2004, 04:44 AM
#4
PowerPoster
VB Code:
Dim i as integer
Dim Ctrl As Control
For i = 1 to 10
For Each Ctrl In Controls
If TypeName(Ctrl) = "Textbox" Then
Ctrl.Text = Ctrl.Text & i
End If
Next Ctrl
Next i
Will go through every textbox on a form and append i to it, so you'll end up with,
TextBox112345678910
in all of them. (hopefully, should work properly )
-
Oct 24th, 2004, 04:46 AM
#5
Thread Starter
Lively Member
can't i just have an endruslt like this
textbox1
textbox2
textbox3 ....
-
Oct 24th, 2004, 04:50 AM
#6
PowerPoster
You sure can.
VB Code:
Dim i As Integer
Dim Ctrl As Control
i = 1
For Each Ctrl In Controls
If TypeName(Ctrl) = "Textbox" Then
Ctrl.Text = "textbox" & i
i = i + 1
End If
Next Ctrl
-
Oct 25th, 2004, 08:18 AM
#7
Thread Starter
Lively Member
i can't let it work
i try't this
Function dagenotitie()
Dim i As Integer
Dim result As Control
For i = 1 To 31
result = "nummer" & i
result.Caption = i
Next i
End Function
wan't work either
result = nothing
-
Oct 25th, 2004, 11:10 PM
#8
PowerPoster
VB Code:
Dim i As Integer
Dim result As Control
For Each result In Controls
For i = 1 To 31
result = "nummer" & i
result.Caption = i
Next i
Next result
Your missing a For Loop that goes through all of the controls. Result will = nothing because you haven't assigned anything to it. It gets assigned a control here,
For Each result In Controls
-
Oct 25th, 2004, 11:49 PM
#9
alternative
VB Code:
For i = 1 To 10
MsgBox Me.Controls("tekst" + i).Text
Next i
-
Oct 26th, 2004, 08:19 AM
#10
Thread Starter
Lively Member
Re: alternative
Originally posted by Deepak Sakpal
VB Code:
For i = 1 To 10
MsgBox Me.Controls("tekst" + i).Text
Next i
this was wrong
Originally posted by Deepak Sakpal
VB Code:
For i = 1 To 10
MsgBox Me.Controls("tekst" & i).Text
Next i
this works perfect
thanks
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
|