PC Review


Reply
Thread Tools Rate Thread

Arrayed controls

 
 
Broadbent
Guest
Posts: n/a
 
      16th Dec 2003
I have just started using VB7 so I am new to all this.
In VB6 I used to array controls, but I notice that there is no Index
property in the VB7 controls. What's the answer please?


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      16th Dec 2003
"Broadbent" <(E-Mail Removed)> schrieb
> I have just started using VB7 so I am new to all this.
> In VB6 I used to array controls, but I notice that there is no
> Index property in the VB7 controls. What's the answer please?


The former control arrays are not required anymore.

If you want to access controls by an index instead of by a more expressive
name, add them to an array:

dim m_labels() as label
'...
m_labels = new label(){lblName, lblStreet, lblWhatever}


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
Hi,

http://msdn.microsoft.com/library/de...et05132003.asp

Ken
----------------------
"Broadbent" <(E-Mail Removed)> wrote in message
news:brmpj0$iqt$(E-Mail Removed)...
> I have just started using VB7 so I am new to all this.
> In VB6 I used to array controls, but I notice that there is no Index
> property in the VB7 controls. What's the answer please?
>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      16th Dec 2003
Hi Broadbent

In addition to Ken

If you want it it is easy to make a control array here is a sample

\\\
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 to drag a groupbox1
'and 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


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
* "Broadbent" <(E-Mail Removed)> scripsit:
> I have just started using VB7 so I am new to all this.
> In VB6 I used to array controls, but I notice that there is no Index
> property in the VB7 controls. What's the answer please?


Creating Control Arrays in Visual Basic .NET and Visual C# .NET
<http://msdn.microsoft.com/library/?url=/library/en-us/dv_vstechart/html/vbtchCreatingControlArraysInVisualBasicNETVisualCNET.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dis-arrayed arrays Mini Mouse Microsoft C# .NET 2 29th Jan 2008 06:38 PM
Controls.Count, Controls.IsSynchronized, and Controls.SyncRoot Nathan Sokalski Microsoft ASP .NET 4 5th Sep 2007 04:27 AM
Excel Flavour in a Named Formula, Regular or Arrayed ? tkt_tang@hotmail.com Microsoft Excel Programming 1 6th Dec 2005 09:16 AM
Message box breaks owner draw controls in .NET controls used as ActiveX controls (again) Clive Dixon Microsoft Dot NET Framework Forms 0 26th May 2004 10:15 AM
redim in a web service with arrayed structors/"Redim statement requires Array" Daryl Davis Microsoft VB .NET 4 10th Feb 2004 06:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.