Hi,
I've many texboxes called txt1,txt2,...,txtn, the number isn't known at the
design time because they are created by code.
I'm looking for a way to use them folowing of an iterator i
txti.text="value"
In another languages (vb6???) I used the operator &: txt&i
how does it work in vb.net? 5 2207
Hi Touf,
I did made a sample with chekboxes yesterday, but it is of course almost the
same with textboxes.
\\\
Private myCheckbox(10) As CheckBox
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'you need for this sample to drag a button on the form
Dim start As Integer = 4
Dim top As Integer = 18
Dim i As Integer
For i = 1 To 10
myCheckbox(i) = New CheckBox
myCheckbox(i).TextAlign = ContentAlignment.MiddleCenter
myCheckbox(i).Width = 40
myCheckbox(i).Height = 20
myCheckbox(i).Location = New System.Drawing.Point(start, top)
myCheckbox(i).Text = i.ToString
myCheckbox(i).Cursor = Cursors.Hand
Me.GroupBox1.Controls.Add(myCheckbox(i))
AddHandler myCheckbox(i).Click, AddressOf myCheckBox_Click
start = start + 40
If i = 5 Then
top = top + 20
start = 4
End If
Next
End Sub
Private Sub myCheckBox_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim chk As CheckBox
chk = DirectCast(sender, CheckBox)
Dim i As String = chk.Text
End Sub
Private Sub Button1_Click _
(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim a As New System.Text.StringBuilder
a.Remove(0, a.Length)
Dim i As Integer
For i = 1 To 10
If myCheckbox(i).Checked Then
a.Append(i.ToString)
End If
Next
MessageBox.Show(a.ToString)
End Sub
///
I hope this helps a little bit
Cor
Hi Touf,
One way is to add them to an array or ArrayList when you create them.
If you use an array, you'll be able to give it the correct type but you'll
have to keep ReDimensioning it as you go, or create it large enough for the
maximum possible and then ReDim down to size.
Dim aoTestBoxes (MoreThanEnough) As TestBox
... Add to aoTestBoxes ...
ReDim Preserve aoTestBoxes (NumTextBoxes)
aoTestBoxes (I).Text = "value"
If you use an ArrayList, it will grow as required but you'll have to cast
the items in order to use them:
Dim alTestBoxes As ArrayList
DirectCast (alTestBoxes (I), TextBox).Text = "value"
Regards,
Fergus
"touf" <to******@hotmail.com> schrieb Hi, I've many texboxes called txt1,txt2,...,txtn, the number isn't known at the design time because they are created by code. I'm looking for a way to use them folowing of an iterator i txti.text="value"
In another languages (vb6???) I used the operator &: txt&i how does it work in vb.net?
Add the textboxes to an array, then you can use i as the index in the array,
and you can give the textboxes expressive names (if you want).
--
Armin
Thanks.
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:e9**************@tk2msftngp13.phx.gbl... Hi Touf,
One way is to add them to an array or ArrayList when you create them.
If you use an array, you'll be able to give it the correct type but
you'll have to keep ReDimensioning it as you go, or create it large enough for
the maximum possible and then ReDim down to size. Dim aoTestBoxes (MoreThanEnough) As TestBox ... Add to aoTestBoxes ... ReDim Preserve aoTestBoxes (NumTextBoxes) aoTestBoxes (I).Text = "value"
If you use an ArrayList, it will grow as required but you'll have to
cast the items in order to use them: Dim alTestBoxes As ArrayList DirectCast (alTestBoxes (I), TextBox).Text = "value"
Regards, Fergus
"touf" <to******@hotmail.com> scripsit: I've many texboxes called txt1,txt2,...,txtn, the number isn't known at the design time because they are created by code. I'm looking for a way to use them folowing of an iterator i txti.text="value"
Creating Control Arrays in Visual Basic .NET and Visual C# .NET
<http://msdn.microsoft.com/library/?url=/library/en-us/dv_vstechart/html/vbtchCreatingControlArraysInVisualBasicNETVisualCN ET.asp>
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Davis |
last post by:
I'd like to overload 'comma' to define a concatenation operator for
integer-like classes. I've got some first ideas, but I'd appreciate a
sanity check. The concatenation operator needs to so...
|
by: joesoap |
last post by:
Hi can anybody please tell me what is wrong with my ostream operator???
this is the output i get using the 3 attached files.
this is the output after i run assignment2
-joesoap
#include...
|
by: Jason |
last post by:
Hello. I am trying to learn how operator overloading works so I wrote
a simple class to help me practice. I understand the basic opertoar
overload like + - / *, but when I try to overload more...
|
by: JKop |
last post by:
Using MSWindows as an example:
On MSWindows, there's a thing called the System Registry, which is a really
big database that holds all the settings of the OS. There's API's for
working with the...
|
by: Martin Magnusson |
last post by:
I have defined a number of custom stream buffers with corresponding in
and out streams for IO operations in my program, such as IO::output,
IO::warning and IO::debug. Now, the debug stream should...
|
by: Sensei |
last post by:
Hi.
I have a problem with a C++ code I can't resolve, or better, I can't see
what the problem should be!
Here's an excerpt of the incriminated code:
=== bspalgo.cpp
// THAT'S THE BAD...
|
by: YUY0x7 |
last post by:
Hi, I am having a bit of trouble with a specialization of operator<<.
Here goes:
class MyStream
{
};
template <typename T>
MyStream& operator<<(MyStream& lhs, T const &)
|
by: Steven T. Hatton |
last post by:
I'll admit, so far in my C++ experience, I've left ADL to the realm
of 'magic happens'. I really don't know when I might be using it. Can
someone provide examples of how ADL changes the behavior...
|
by: Piotr Sawuk |
last post by:
What is wrong with the following? Why doesn't it compile?
template<int f, class me, typename ValType=int>
class Fm
{
protected:
ValType v;
public:
me& operator+=(const me& o)...
|
by: Frank Bergemann |
last post by:
i don't manage to get this compiled:
// shall map compare operator ids to proper std::binary_function's
// for this instantiated for various types
template <typename ForType>
struct...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
| |