473,378 Members | 1,360 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,378 software developers and data experts.

Controls Problem

I have this PROBLEM with controls collection:

The old VB 6.0 syntax was:

MyStr = me.controls("button1").text

VB .NET doesn't function in this way, because in .NET
I must know the index of the control! I need to use the
STRING NAME of the control to address the object, because
my target is doing something like this:
for i = 1 to 10
MyStr(i) = me.controls("button" & i ).text
next i
if I use this:

MyStr = me.controls(IndexOf(button1)).text

I have again the same problem: cannot use the STRING NAME
of the object!
Nov 20 '05 #1
4 979
u used this ....

MyStr(i) = me.controls.text.substring("blah" & i) or u can used tostring(..)
or u can do stringbuilder.
kindly read book. recommended microsoft press book. or search in google

index is no longer in vb.net.
regards

Gigaworld wrote:
I have this PROBLEM with controls collection:

The old VB 6.0 syntax was:

MyStr = me.controls("button1").text

VB .NET doesn't function in this way, because in .NET
I must know the index of the control! I need to use the
STRING NAME of the control to address the object, because
my target is doing something like this:
for i = 1 to 10
MyStr(i) = me.controls("button" & i ).text
next i
if I use this:

MyStr = me.controls(IndexOf(button1)).text

I have again the same problem: cannot use the STRING NAME
of the object!


Nov 20 '05 #2
Dim found as Boolean = False
Dim c as Control
For each c in form.controls

if c.name="YourControlName" Then
Found=true
Exit Next
End IF

Next

If Found then ' c point to your control so . . .

'..... Do Stuff ......

End If

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Gigaworld" <se*****@gigaworld.it> wrote in message
news:NK***********************@news3.tin.it...
I have this PROBLEM with controls collection:

The old VB 6.0 syntax was:

MyStr = me.controls("button1").text

VB .NET doesn't function in this way, because in .NET
I must know the index of the control! I need to use the
STRING NAME of the control to address the object, because
my target is doing something like this:
for i = 1 to 10
MyStr(i) = me.controls("button" & i ).text
next i
if I use this:

MyStr = me.controls(IndexOf(button1)).text

I have again the same problem: cannot use the STRING NAME
of the object!

Nov 20 '05 #3
Dim myStr As String
Dim myControl As Control
For Each myControl In Me.Controls
If TypeOf myControl Is Button AndAlso myControl.Name = "button1" Then
myStr = myControl.Text
Exit For
End If
Next

Nov 20 '05 #4
* "Gigaworld" <se*****@gigaworld.it> scripsit:
[...]

No multiposts please!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

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

Similar topics

6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.