473,699 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I change more than one control's properties at the same time?

Can I use some loop to change a series of control's properties at same time?

for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text=" 2", textbox3.text=" 3"......

Can I use some loop method to do this?
Nov 20 '05 #1
15 1516
Cor
Hi Mike,
Can I use some loop to change a series of control's properties at same time? for example. I have textbox1, textbox2, textbox3, ...
If I want textbox1.text = "1", textbox2.text=" 2", textbox3.text=" 3"......
Can I use some loop method to do this?


If it is for a windowform where the controls are direct on the page you can
use this
(Watch typos I type it here but it is very simple so I do not expect them)

\\\
For each ctr as control in me.controls
if typeof ctr Is Textbox then
ctr.text = ctr.name.substr ing(7)
end if
next

This goes because text is a proporty from controls.
If you did want to change the " lines", than you have to write
\\\
directcast(ctr, textbox).lines = ctr. etc etc
///

I hope this helps?

Cor


Nov 20 '05 #2
Use following:

Dim obj As Object

Dim i As Integer

For Each obj In Me.Controls

For i = 1 To 3

If obj.name = "textbox" & i Then

obj.text = i

End If

Next

Next

Vikram

"Mike Chan" <ia*@mikechan.n et> wrote in message
news:O5******** ******@tk2msftn gp13.phx.gbl...
Can I use some loop to change a series of control's properties at same time?
for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text=" 2", textbox3.text=" 3"......

Can I use some loop method to do this?

Nov 20 '05 #3
* "Mike Chan" <ia*@mikechan.n et> scripsit:
Can I use some loop to change a series of control's properties at same time?

for example. I have textbox1, textbox2, textbox3, ...

If I want textbox1.text = "1", textbox2.text=" 2", textbox3.text=" 3"......

Can I use some loop method to do this?


Quick and dirty:

\\\
Dim t() As TextBox = {TextBox1, TextBox2, ...}
Dim i As Integer
For i = 0 to t.Length - 1
t(i).Text = (i + 1).ToString()
Next i
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Cor
Hi Herfried,

Are you using this one now also?

\\
Dim t() As TextBox = {TextBox1, TextBox2, ...}
Dim i As Integer
For i = 0 to t.Length - 1
t(i).Text = (i + 1).ToString()
Next i
///

Is nice is it not?

I was in doubt which one I would supply.

Cor
Nov 20 '05 #5
Cor,

* "Cor" <no*@non.com> scripsit:
Are you using this one now also?

\\
Dim t() As TextBox = {TextBox1, TextBox2, ...}
Dim i As Integer
For i = 0 to t.Length - 1
t(i).Text = (i + 1).ToString()
Next i
///

Is nice is it not?

I was in doubt which one I would supply.


Sorry, I don't understand what you want to tell me.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Cor
Hi Herfried,

In past you where only using the for each loop.

This one came from a message an OP supplied, where we first thought it would
not work but after some investigation it did (Armin and I have been very
busy with it).

I thought you where a little bit sceptic about it, but now I see you are
advising it.
\\
Dim t() As TextBox = {TextBox1, TextBox2, ...}
Dim i As Integer
For i = 0 to t.Length - 1
t(i).Text = (i + 1).ToString()
Next i
///


Cor
Nov 20 '05 #7
Cor
Hi Herfried,

Before you misunderstand it.

As the OP supplied it, it did not work, it was the investigation that did
make it work.

Cor
Nov 20 '05 #8
* "Cor" <no*@non.com> scripsit:
In past you where only using the for each loop.


I am a fan of 'For...Each' loops, I don't know why I didn't use a
'For...Each' loop in this "snippet".

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
Cor
Hi Herfried,

Look at the one I did use this time, that is the one you have always used.

I did wanted to be cooperative this time and used yours and now you took my
newest sample.

That is all, however I am glad, because now I know that new one is a good
one.

:-))

Cor
In past you where only using the for each loop.


I am a fan of 'For...Each' loops, I don't know why I didn't use a
'For...Each' loop in this "snippet".

Nov 20 '05 #10

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

Similar topics

8
16664
by: deko | last post by:
I'm trying to find a way to set form/control properties programmatically. In a nut shell: 1. Open a database 2. Open a form in design view 3. Do something like this: For Each prp In frm.Properties If prp.Name = rst!PropName Then prp = rst!ChangeTo
13
6090
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which during production. Usually, this only wraps code used to control quitting the whole app versus just shutting a form, but it can also control many other things. However, as part of the build before delivering an update, I have to remember to...
5
1438
by: ~~~ .NET Ed ~~~ | last post by:
Well, maybe not half-baked but 75%. I find very frustrating working with the DataGrid control. It offers a lot of functionality which really comes in handy. Unfortunately you can only enjoy a DataGrid to its fullest when you "drop" it on a web form. There you can modify all sorts of properties for the look and behaviour to your hearts content. But then, when you decide to use the DataGrid as a child control of a web custom composite...
4
2239
by: Steve Amey | last post by:
Hi all I have a Form that is inherited from a main form. On the child form I am putting 2 panels directly on the form, not in any other controls. If I build the project, 1 of the panels decides to re-size itself, but the other one doesn't. Obviously, I don't want the panels re-sizing every time I perform a build. Has any-one encountered this behaviour at all? If I look at the code in the form, the size of the panel is correct, but...
3
11002
by: RG | last post by:
For a Windows project in VB.NET 2003: I need a Calendar that’s much larger than the MonthCalendar control in the toolbox; it needs to fill the whole screen (at least approximately ). VB won’t allow me to change the Size Height or Width Properties. I see that you can size a Calendar control in a Web project all you like; but I’m creating a Windows application project here. I see that Size comes from System.Drawing.Size...
0
1906
by: jaawaad | last post by:
I'm creating webcharts control dynamically based on user input as to how many charts they would like to see. I'm running into problem as to how to set properties for those charts at run time so they behave and look all the same. Creating dynamic chart code looks something like this.... ///////////////////////////////////////////////////////////////////////////////// Sub CreateChartControl(ByVal sender As Object, ByVal e As EventArgs)...
9
33787
by: iwdu15 | last post by:
hi, is there any way (vb.net 2003 or 2005) to change the progress bar color from blue to any other system color? im trying to change between 3 colors depending on a variable in my app. unfortunatly i didnt see any property or method to do this so i was wondering if i was missing something or if il have to write my own. Thanks -- -iwdu15
3
5466
by: Michael Chambers | last post by:
Hi there, Is there a clean way to change a property or method's attribute in a derived class without redefining the property/method itself. That is, redefining the property/method in the derived class simply to change its attribute is ugly IMO. I assume you can do this and then simply defer to the base class version but it's unwieldy so I'm wondering if there's a better way. Thanks in advance.
11
7451
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
0
8689
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6534
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.