473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to create control arrays in vb.net

seshu
156 100+
Hi Everybody
Earlier i used to write vb6 code there when ever i copy a textbox and past on same form it used to ask me should i create textbox arrays if i say yes the name used to be like this textbox(0),textbox(1) etc but now in vb.net it is not happenning so

So what i ask is is there any option like that are any controle so that my length of the code decreases and even to study the code it will be eassy
so someone please help me out

Regards
Seshu
May 29 '07 #1
6 2807
dip_developer
648 Expert 512MB
Hi Everybody
Earlier i used to write vb6 code there when ever i copy a textbox and past on same form it used to ask me should i create textbox arrays if i say yes the name used to be like this textbox(0),textbox(1) etc but now in vb.net it is not happenning so

So what i ask is is there any option like that are any controle so that my length of the code decreases and even to study the code it will be eassy
so someone please help me out

Regards
Seshu
draw a panel or groupbox..................
place your controls there....
you can use .NET control class to write your code
like that.
Expand|Select|Wrap|Line Numbers
  1. For Each ctl As Control In Panel1.Controls
  2.                                If ctl.Text = "" Then
  3.                     MsgBox("DONT LEFT ANY FIELD BLANK WHILE SAVING",  MsgBoxStyle.Critical, "BLANK FIELDS!!!")
  4.                     Exit Sub
  5.                 End If
  6.             Next
May 29 '07 #2
SammyB
807 Expert 512MB
Hi Everybody
Earlier i used to write vb6 code there when ever i copy a textbox and past on same form it used to ask me should i create textbox arrays if i say yes the name used to be like this textbox(0),textbox(1) etc but now in vb.net it is not happenning so

So what i ask is is there any option like that are any controle so that my length of the code decreases and even to study the code it will be eassy
so someone please help me out

Regards
Seshu
It is annoying not to have the VB6 control arrays, but you really don't need them since you can assign an interrupt routine to more than one control: in the properties window, click on the lighting bolt at the top, find the event then use the drop-down to use the same routine as another object. Also, you can make your own arrays/generics of controls. For a rather lengthly example, see http://www.thescripts.com/forum/thread639373.html. Just skip over the first, posts before #9 were using VB6.
May 29 '07 #3
.NET is so much richer for accessing and manipulating controls and their events, control arrays really aren't necessary.
But if you searched your .NET documents for "control arrays" you'd get a return on the article "Life Without Control Arrays in Visual Basic .NET", http://msdn2.microsoft.com/en-us/lib...42(VS.71).aspx, which may help you.
It mentioned a compatibility library that actually gives you back control arrays.
May 29 '07 #4
Plater
7,872 Expert 4TB
If you go to Add Components on your toolbox, you will see various arrays of controls listed (and unchecked) You can ad them there.

I used to miss that, but I found that after adjusting to not having them, I much prefer without them.

NOTE: You can always name your controls like mytextbox1 mytextbox2 and then use the .Controls collection that every widget has.
Expand|Select|Wrap|Line Numbers
  1. for (int i=0;i<2i++)
  2. {
  3.    this.Controls["mytextbox"+i.ToString()]
  4. }
  5.  
May 29 '07 #5
SammyB
807 Expert 512MB
If you go to Add Components on your toolbox, you will see various arrays of controls listed (and unchecked) You can ad them there.
This sounds very cool, but I cannot find "Add Components." Ah, never mind, I see it, for VS 2005, it is right-click in Toolbox, Choose Items, but dangerous, notice that they are all in Compatibility.VB6 library.

Also, from the excellent article that OO referenced, http://msdn2.microsoft.com/en-us/lib...42(VS.71).aspx
Note Actually, Visual Basic .NET does support control arrays through the Microsoft Visual Basic .NET Compatibility library. This library allows you to retain some of the Visual Basic 6.0 features in Visual Basic .NET to simplify the migration process. Features of this library should be used only for migration.
May 29 '07 #6
seshu
156 100+
My goodness i myself dint expect these many replies but any how now i have come to a conclution that if there is somthing there in vb6 and not there in vb.net then it blindly means that here after no need of such things any how thank you everybody once after reading all these links i will come back to you
Thank you
Bye
May 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Raymond H. | last post by:
Hello, 1- How to see, in a Label, the URL of a link that the mouse pass over? (in the WebBrower control in a vb projet). 2- How to create a menu and a submenu via a button Command1? and...
6
by: Christian Blackburn | last post by:
Hi Gang, I can't seem to figure out how to create an object array in VB.NET 2003. In VB6 you would just select an object copy and paste it and that was that. I don't know why in the heck they...
2
by: Merlin | last post by:
Hi I have a control that allows embeddable editors, so for example I can set a property of controlsEmbeddableEditor =me.TextBox1 on my form, no problem here - what I want to do is the same thing...
3
by: B-Dog | last post by:
I'm capturing the checked radio button to XML file using the name of the radio button. I want to read my xml file to find which button was checked on close and the check the appropriate button...
2
by: John | last post by:
Hello everyone, I'm currently writing a program to keep track of schedule changes at a school. The goal is to have someone using the program to declare changes, then the program writes a html...
14
by: Jim Burns | last post by:
I just started with vb.net and I don't understand why there are no control arrays. what replaced them. I was trying to do drag and drop(What happened with that) and it looked like with no control...
15
by: cj | last post by:
I would like to have menu items a main menu bar that represent the days of the week. When you click on them they alternate from checked to unchecked. Right now I have 7 subs that look like this...
4
by: Arne Beruldsen | last post by:
I'm a recent convert to VB.net from VB6...and I can't believe they don't support control arrays. I have an app that uses a ton of Control Arrays...mostly labels and text boxes. I need some...
5
by: =?Utf-8?B?U2NhbmJveQ==?= | last post by:
Guyz, Whatever happened to the 'Index' property for a control, that used to be present in VB 3.0 / 4.0 / 5.0 / 6.0 and which now seems to be missing from VBE 2005? I need to be able to make 4...
3
by: Richard Hollenbeck | last post by:
Hello, In regular VB, I remember I could create a generic label (call it something like lblFieldNames) and copy it and paste it. VB would say that I already have an object by that name then ask...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.