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

Using Controls Collection

P: n/a
Hi
Im creating customer details form in VB.Net, in that Im getting
Original Details as well as Correspondance details of customer. If both
are same then by clicking checkbox all the text of respective fields
should be filled in correspondance details textboxes. I achieved some
what like this....

Try
Dim i, i1 As Control
Dim j As New TextBox

If CheckBox1.CheckState = CheckState.Checked Then
For Each i In TabControl1.TabPages(0).Controls
If TypeOf i Is TextBox Then
j = New TextBox
If Microsoft.VisualBasic.Mid(i.Name(), Len(i.Name()),
Len(i.Name())) = "1" Then
j.Name = (Microsoft.VisualBasic.Left(i.Name,
Len(i.Name) - 1)).ToString
'i1.Name = j
'i1.Text = "Testing"
i.Text = j.Text
'MsgBox(j.Text)
End If
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message)

But my problem is even I declared "j" as control, Im not getting j.text
as result, alternatively Im getting textboxes name but not textbox.text
values.. please anyone can help....

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sivaprakash,

What you are doing now, is showing the text of a new textbox. That is for
sure empty.

Moreover, because that "Text" is a property of all controls, there is no
need to do any thing (casting or whatever) special for it.

You can just do (not complete your sample that is really to long to good
show the problem. Especially not because that you are using i and j which
are mostly used as standard names for indexers and not as controls)

for each ctr as control in mytabpage(0).controls
if TypeOff ctr is TextBox then
messagebox.show ctr.Text
end if
Next

I hope this helps,

Cor

<si********************@gmail.com> schreef in bericht
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi
Im creating customer details form in VB.Net, in that Im getting
Original Details as well as Correspondance details of customer. If both
are same then by clicking checkbox all the text of respective fields
should be filled in correspondance details textboxes. I achieved some
what like this....

Try
Dim i, i1 As Control
Dim j As New TextBox

If CheckBox1.CheckState = CheckState.Checked Then
For Each i In TabControl1.TabPages(0).Controls
If TypeOf i Is TextBox Then
j = New TextBox
If Microsoft.VisualBasic.Mid(i.Name(), Len(i.Name()),
Len(i.Name())) = "1" Then
j.Name = (Microsoft.VisualBasic.Left(i.Name,
Len(i.Name) - 1)).ToString
'i1.Name = j
'i1.Text = "Testing"
i.Text = j.Text
'MsgBox(j.Text)
End If
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message)

But my problem is even I declared "j" as control, Im not getting j.text
as result, alternatively Im getting textboxes name but not textbox.text
values.. please anyone can help....

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.