473,396 Members | 1,996 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.

textbox question

Hi all,

I would like to create some textbox by coding...such as ..I would like
to create 10 textbox during form load. Is it use for loop to do ? ...on the
other hand, is vb.net can do as the following..

dim str as string
dim tmp as string
dim x a sinteger
str = "textbox"
for x = 1 to 10
tmp = str + cstr(x)
' and then assign value in tmp '
next x

Thanks
Nov 21 '05 #1
5 1146
Edmond,

This is simple

dim textboxes(9) as textbox
for x as integer = 0 to 9
dim mytexbox as new textbox
mytextbox.top = 'etc
mytextbox.name = mytextboxname, x.tostring
textboxes(x) = mytextbox 'to get the values when typed in back
controls.add(mytextbox)
next

I hope this helps,

Cor

Nov 21 '05 #2

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
Edmond,

This is simple

dim textboxes(9) as textbox
for x as integer = 0 to 9
dim mytexbox as new textbox
mytextbox.top = 'etc
mytextbox.name = mytextboxname, x.tostring
textboxes(x) = mytextbox 'to get the values when typed in back
controls.add(mytextbox)
next

I hope this helps,

Cor


And a shorter way:

Dim textBoxes(9) As TextBox

For x As Integer = 0 To 9
textBoxes(x) = New TextBox()
textBoxes(x).Top = y
textBoxes(x).Name = myTextBoxName, x.ToString() ' comma a tab? Can't
remember.
controls.Add(textBoxes(x))
Next

w00t shorter by 1 whole line!!!! :P

hth ;)

Mythran

Nov 21 '05 #3
Mythran,

I did want to show it in its shortest way without the array. However when I
did not showed the array than it would (be when there was not databinding in
the sample) imposible to get the or set the values. Therefore I added it at
the last moment and was to lazy to do it real in the best way.

However

Dim textBoxes(9) As TextBox
For x As Integer = 0 To textBoxes.count -1
textBoxes(x) = New TextBox()
textBoxes(x).Top = y
controls.Add(textBoxes(x))
Next

The name is in my opinion not real needed when it is in an array.

:-)

Cor
Nov 21 '05 #4

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Mythran,

I did want to show it in its shortest way without the array. However when
I did not showed the array than it would (be when there was not
databinding in the sample) imposible to get the or set the values.
Therefore I added it at the last moment and was to lazy to do it real in
the best way.

However

Dim textBoxes(9) As TextBox
For x As Integer = 0 To textBoxes.count -1
textBoxes(x) = New TextBox()
textBoxes(x).Top = y
controls.Add(textBoxes(x))
Next

The name is in my opinion not real needed when it is in an array.

:-)

Cor


Cor,

I was simply showing a shorter way, using your example as a base, and
throwing in some sarcastism about myself :P Wasn't meant to be taken that
your way was too long, just showing that it "can" be shortened...I didn't
want to be too anal retentive and do it all on one line, but at the same
time, rid it of some unnecessary additional code just for kicks. Either way
will work, and I have written code often enough using a variable that really
wasn't necessary for all practical purposes :)

But in any sense, sorry that I didn't make myself clear enough about why I
posted the shorter version. It wasn't to tickle anybody's fancy (darn),
just to broaden the minds of others....like that ever happens with my
posts...

Mythran

Nov 21 '05 #5
thx a lot...
"Cor Ligthert" <no************@planet.nl> ¦b¶l¥ó
news:OJ**************@TK2MSFTNGP14.phx.gbl ¤¤¼¶¼g...
Edmond,

We are really going step by step.
See this sample from me by doing it with buttons in this message

http://groups-beta.google.com/group/...2d00c26d?hl=en
This is about buttons so have a look alone to the addhandler and the event
itself.

I hope this helps a little bit?

Cor

Nov 21 '05 #6

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

Similar topics

2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Devinim ÞÖLEN | last post by:
Hi; I try to fetch data and show in the textbox as follows; .. .. .. .. <asp:XmlDataSource Id="m_ChXmlDataSource" runat="server"...
3
by: Henry | last post by:
Hi. I've also posted this at another discussion board and here is the original question. ------------------------- "I have this problem and I don't know what I can do. First of all, I have a...
2
by: Jon | last post by:
Hello All, I have a datalist whose itemtemplate contains a label and a textbox. The label text is set on itemdatabound with the text, which is a question, from the database column. Each question...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
1
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of...
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
10
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75...
4
by: Randy | last post by:
My situation is that I have a form on which a number of textboxes and comboboxes are added dynamically based on interaction with the user. As these controls are added, they are given names based on...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.