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
Printable View
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
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?
yes i'm trying to get a lot of textboxes at once
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 :p)
can't i just have an endruslt like this
textbox1
textbox2
textbox3 ....
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
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
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
VB Code:
For i = 1 To 10 MsgBox Me.Controls("tekst" + i).Text Next i
this was wrongQuote:
Originally posted by Deepak Sakpal
VB Code:
For i = 1 To 10 MsgBox Me.Controls("tekst" + i).Text Next i
this works perfectQuote:
Originally posted by Deepak Sakpal
VB Code:
For i = 1 To 10 MsgBox Me.Controls("tekst" & i).Text Next i
thanks