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

VB2005 Control Arrays

Just looking for thoughts on converting VB6 Control arrays.

Here's the way I did it. The control happens to be a Usercontrol, CircVol,
but could be any control.

I would appreciate any suggestions on a better way to do it.

GalenS
DECLARATION
Public UserSwp As ArrayList

FORM_LOAD
BuildUserSwp()

BUILD
Private Sub BuildUserSwp()
UserSwp = New ArrayList
UserSwp.Add(CircVol1)
UserSwp.Add(CircVol2)
UserSwp.Add(CircVol3)
UserSwp.Add(CircVol4)
UserSwp.Add(CircVol5)
UserSwp.Add(CircVol6)
End Sub
BUTTON_CLICK
Private Sub UserSwpAll_Click(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles CircVol1.Click, CircVol2.Click, CircVol3.Click, CircVol4.Click,
_
CircVol5.Click, CircVol6.Click
Dim Index As Integer
Select Case sender.name
Case "CircVol1"
Index = 0
Case "CircVol2"
Index = 1
Case "CircVol3"
Index = 2
Case "CircVol4"
Index = 3
Case "CircVol5"
Index = 4
Case "CircVol6"
Index = 5
End Select
gCtrls.ChnVol(Index) = CByte(UserSwp(Index).volval)
Call UpdatePots(Index, gCtrls.ChnVol(Index))
End Sub

PARTIAL USAGE
For Index = 0 To 4
UserSwp(Index).circName = Chr(Inner)
UserSwp(Index).Width = 90
UserSwp(Index).Height = 97
UserSwp(Index).circBackColor = Me.BackColor
Call SetControl(Index, gCtrls.ChnVol(Index))
LabControl(Index).Text = Chr(Inner)
Inner = Inner + 1
Next
UserSwp(5).Name = "LUNG"
UserSwp(5).circBackColor = Me.BackColor

ANOTHER USAGE
For Index = 1 To 6
gCtrls.ChnVol(Index - 1) = gbytEPA(Index)
frmSweep.UserSwp(Index - 1).VolVal = gbytEPA(Index)
Next Index
Apr 19 '06 #1
5 2265
Rather than the name, I prefer to use the tag property and give it an
integer. If your tag is already used for something else and you want a
design-time array, I would probaby parse my name string instead of
using brute force; maybe write a function that strips all alpha
characters off the senders name and returns only the number.

For run-time created arrays, I can add a handle one at a time.

For X=... to ...
....
Control=new button
Control.Tag=X
' Set location and size
myForm.Controls.Add(Control)
AddHandler Control.Click, AddressOf Button_Click

....
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
with DirectCast(Sender, Button) ' Avoids late binding. It probably
doesn't hurt speed much, though. I do it for intellisense rather than
speed anyway.
' Use ".tag" to see which button it is.

Apr 19 '06 #2
Some good points. I printed it out and will wait to see if other ideas are
forthcoming.

Thanks
GalenS

"creator_bob" <ro************@hotmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Rather than the name, I prefer to use the tag property and give it an
integer. If your tag is already used for something else and you want a
design-time array, I would probaby parse my name string instead of
using brute force; maybe write a function that strips all alpha
characters off the senders name and returns only the number.

For run-time created arrays, I can add a handle one at a time.

For X=... to ...
...
Control=new button
Control.Tag=X
' Set location and size
myForm.Controls.Add(Control)
AddHandler Control.Click, AddressOf Button_Click

...
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
with DirectCast(Sender, Button) ' Avoids late binding. It probably
doesn't hurt speed much, though. I do it for intellisense rather than
speed anyway.
' Use ".tag" to see which button it is.

Apr 19 '06 #3
Hi Galen,

I think the following articles should be helpful to you:
"Getting Back Your Visual Basic 6.0 Goodies"
http://msdn.microsoft.com/library/de...us/dnadvnet/ht
ml/vbnet05132003.asp
"Creating Control Arrays in Visual Basic .NET and Visual C# .NET"
http://msdn.microsoft.com/library/de...us/dv_vstechar
t/html/vbtchCreatingControlArraysInVisualBasicNETVisualCN ET.asp
"Accessing controls by their names or indices"
http://dotnet.mvps.org/dotnet/faqs/?...eindex&lang=en

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
==============

Apr 20 '06 #4
Very interesting but I still like my method better. I will probably modify
per "Creator_bob's" suggestions.

Since I refer to these controls throughout my program I like to use
MyButton(index).Checked instead of stuff like

Dim obj As Object
Dim iCount As Integer = 0
For Each obj In colMyCheckBoxes
If TypeOf obj Is CheckBox Then
Dim chkCheckBox As CheckBox
chkCheckBox = CType(obj, CheckBox)
If chkCheckBox.Checked Then
iCount += 1
End If
End If
Next

GalenS

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.com> wrote in message
news:pY**************@TK2MSFTNGXA01.phx.gbl...
Hi Galen,

I think the following articles should be helpful to you:
"Getting Back Your Visual Basic 6.0 Goodies"
http://msdn.microsoft.com/library/de...us/dnadvnet/ht
ml/vbnet05132003.asp
"Creating Control Arrays in Visual Basic .NET and Visual C# .NET"
http://msdn.microsoft.com/library/de...us/dv_vstechar
t/html/vbtchCreatingControlArraysInVisualBasicNETVisualCN ET.asp
"Accessing controls by their names or indices"
http://dotnet.mvps.org/dotnet/faqs/?...eindex&lang=en

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
==============

Apr 20 '06 #5
Ok, if you need further help, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 21 '06 #6

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

Similar topics

7
by: guy | last post by:
Has anyone any experience of the conversion wizard for VB6 to VB2005? if so how good is it? also how does it handle database related conversions i.e is ADO converted to ADO.NET etc. the project...
9
by: bz | last post by:
the vb.upgrade group is dead. I think I will post this here instead. Hi, I ran the Upgrade Wizard to upgrade my VB6 project to VB2005 Express Edition. I got 140 errors and 170 warnings. ...
2
by: johni58 | last post by:
I have several VB6 applications that I am rewriting in VB2005 Express. I used invisible control arrays to place labels over snapshots on a thumbnail screen. Choosing one of the thumbs would open the...
92
by: =?Utf-8?B?bW9iaWxlbW9iaWxl?= | last post by:
I'm trying to load this structure for a call to DeviceIoControl: typedef struct _NDISUIO_QUERY_OID { NDIS_OID Oid; PTCHAR ptcDeviceName; UCHAR Data; } NDISUIO_QUERY_OID, *PNDISUIO_QUERY_OID; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.