473,396 Members | 2,154 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,396 software developers and data experts.

Array of textbox

How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90)
text(myNumber).backcolor=vbRed

Tanks

Angel

Oct 16 '08 #1
7 19887
On Oct 16, 9:34*am, "Angel López" <angel.lopezgo...@salesianos.edu>
wrote:
How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90)
text(myNumber).backcolor=vbRed
You can't make a control array in design mode, but you can emulate it
by creating the controls at run time.

I have created an array of picturebox controls to display a variable
number of images on a form. I did this in C#.NET but I don't see why
it can't be done with VB.NET.
Oct 16 '08 #2
You can use an array of textboxes as you would do with any other array...
For example in Form_Load :

Const Max As Integer = 10
Dim TextBoxes(Max) As TextBox
For i = 0 To Max
TextBoxes(i) = New TextBox
TextBoxes(i).Top = i * TextBoxes(i).Height
Controls.Add(TextBoxes(i))
Next

You just won't have design time support (you could also use a textbox as a
"model"). See http://msdn.microsoft.com/en-us/libr...8a(VS.80).aspx
for details...

Or do you need details such as Rnd being Math.Rand or vbRed being
System.Drawing.Color.Red ?

--
Patrice

"Angel López" <an**************@salesianos.edua écrit dans le message de
groupe de discussion : e4**************@TK2MSFTNGP03.phx.gbl...
How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90)
text(myNumber).backcolor=vbRed

Tanks

Angel
Oct 16 '08 #3
"Angel López" <an**************@salesianos.eduschrieb
How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90) text(myNumber).backcolor=vbRed
Put all textboxes in an array before, for example:

Public Class Form1

Dim textboxes As TextBox()

Private Sub Form1_Load( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load

textboxes = New TextBox() {TextBox1, TextBox2, TextBox3}
End Sub

End Class
(no, there are no "control arrays" anymore...)
Armin

Oct 16 '08 #4
Zack,

In my idea are you mixing up using the designer to create something and
runtime.

You can make something at runtime by using reflection, however mostly and
more save is to do it at design time by code.

Both Armin and Patrice give samples for this, where I like the sample from
Armin the most because he uses the designer to create the labels.
As long as that the labels are not moving over the screen, then there is in
my idea not any reason to make them dynamicly.

jmo

Cor

<za***@construction-imaging.comwrote in message
news:8c**********************************@k16g2000 hsf.googlegroups.com...
On Oct 16, 9:34 am, "Angel López" <angel.lopezgo...@salesianos.edu>
wrote:
How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90)
text(myNumber).backcolor=vbRed
You can't make a control array in design mode, but you can emulate it
by creating the controls at run time.

I have created an array of picturebox controls to display a variable
number of images on a form. I did this in C#.NET but I don't see why
it can't be done with VB.NET.

Oct 17 '08 #5
Armin,

I hope you don't mind, just your opinion, would it not be better to use the
text

"There are no VB6 control arrays anymore"

Probably like you I think the OP is a classic VB6 user, however others who
never used that can be confused.

You show a true control arrays in your code.

Just writing what I was thinking when I saw your text.

Cor

"Armin Zingler" <az*******@freenet.dewrote in message
news:u2**************@TK2MSFTNGP04.phx.gbl...
"Angel López" <an**************@salesianos.eduschrieb
>How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90) text(myNumber).backcolor=vbRed

Put all textboxes in an array before, for example:

Public Class Form1

Dim textboxes As TextBox()

Private Sub Form1_Load( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load

textboxes = New TextBox() {TextBox1, TextBox2, TextBox3}
End Sub

End Class
(no, there are no "control arrays" anymore...)
Armin
Oct 17 '08 #6
"Cor Ligthert[MVP]" <No************@planet.nlschrieb
Armin,

I hope you don't mind, just your opinion, would it not be better to
use the text

"There are no VB6 control arrays anymore"

Probably like you I think the OP is a classic VB6 user, however
others who never used that can be confused.

You show a true control arrays in your code.

Just writing what I was thinking when I saw your text.
Hi Cor, :-)

sorry, but this is really not my problem. I answered Angel who obviously
knows what "control arrays" mean in this context. I really can not care
about any reader that will read my message in the future without knowing
what we are talking about. Of course you are right that I meant "VB6 control
arrays". Thx for the correction on behalf of all future readers.

BTW, the term was in double quotes, and, if I had meant an array of
controls I would have named them array of controls. (w/o double qoutes) ;-)

You should have better mentioned that 'textboxes' should not be declared
locally but outside the method as a field of the class (which I was too lazy
to correct). ;-)

There are worse things as we both know. :)
Armin

Oct 17 '08 #7
TANKS to every body

Regards from Spain

"Angel López" <an**************@salesianos.eduescribió en el mensaje
news:e4**************@TK2MSFTNGP03.phx.gbl...
How to do this with Vb.net 2008???

myNumber=1+ Int(Rnd()*90)
text(myNumber).backcolor=vbRed

Tanks

Angel

Oct 17 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bhavin | last post by:
Anybody quickly replies it, would be a great help! I try to create dynamic array of textboxes control in ASP.NET(C#). I got the following error while I tried to assign value to ID property of...
3
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if...
1
by: GL | last post by:
I am trying to develop a prgram that randomly selects numbers for an addition program, then when the check answer button is pressed it colors the answer text field either green or red depending if...
4
by: Rich | last post by:
Hello, I have 3 textboxes and 1 combobox on a form. On entering the control I want to select all the text. I can make an array of textboxes like this: Dim arrTxt As TextBox() = {txt1, txt2,...
6
by: Rich | last post by:
Hello, I have an application that contains several checkboxes. I originally created this app in VB.Net 2003 and upgraded the app to VB.Net 2005. I understand the vb2005 supports control...
9
by: jan82 | last post by:
Hi everybody I declared a private static array of textboxes at the top of a class, then i generate the array elements (new textbox()) in a separate function (private void in the same class), ...
3
by: Jacob.Bruxer | last post by:
Hi, I want to be able to append text using a For loop to each textbox in an array of textboxes that I've created, called tBoxes(). Basically I want to add a number of spaces to each textbox in...
2
by: gmb | last post by:
(.NET 2.0) code: array<TextBox^^dialog_txb = {gcnew TextBox(),gcnew TextBox(),gcnew TextBox(),gcnew TextBox(),gcnew TextBox()}; question: Is there a shorter way to declare and initialize an...
1
by: Nightfarer | last post by:
Hello. I have a big trouble using System.Array class (it's the first time I use it) for a software I'm developing. I have a form with a textbox(numbers) and one button (done). Once the number...
9
by: =?Utf-8?B?R2Vla0JveQ==?= | last post by:
I did not see another group for this so I presume this is the correct one to ask such a question. Anyway, I need to get data entered into a textbox and put it all into an array. I have looked...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.