Indexes vba to .net

  • Thread starter Thread starter markh
  • Start date Start date
M

markh

In access/vba any form contains a set of 10 text boxes, named AB1 to AB 10.
In my VBA module i could step through them with the following code:

Dim formcell As textbox

for x - 1 to 10
formcellstr = "AB" $ X
set formcell = forms!form1(formcellstr)
formcell.text = "abcdefg"
next x

Is there anyway i can do this in VB.Net


thanks in advance
Markh
 
Hi,

Try something like this

For Each ctrl As Control In Me.Controls

If TypeOf ctrl Is TextBox Then DirectCast(ctrl, TextBox).Text = "abcdef"

Next



Ken

===============

"markh" <f> wrote in message In access/vba any form contains a set of 10 text boxes, named AB1 to AB 10.
In my VBA module i could step through them with the following code:

Dim formcell As textbox

for x - 1 to 10
formcellstr = "AB" $ X
set formcell = forms!form1(formcellstr)
formcell.text = "abcdefg"
next x

Is there anyway i can do this in VB.Net


thanks in advance
Markh
 
Thankyou for the reply, we have tried this way of coding but found it tobe
inefficient in the example we are using it in. Is there any other ways that
allow us to step through the text boxes efficiently. Thanks again

Markh
 
Just to extend kens response

Dim x As Integer
Dim formcell As Control
For Each formcell In Me.Controls
For x = 1 To 10
If formcell.Name = "AB" & x Then
CType(formcell, TextBox).Text = "abcdefg" & x
Exit For
End If
Next x
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top