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(Cir cVol1)
UserSwp.Add(Cir cVol2)
UserSwp.Add(Cir cVol3)
UserSwp.Add(Cir cVol4)
UserSwp.Add(Cir cVol5)
UserSwp.Add(Cir cVol6)
End Sub
BUTTON_CLICK
Private Sub UserSwpAll_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) _
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(I ndex) = CByte(UserSwp(I ndex).volval)
Call UpdatePots(Inde x, gCtrls.ChnVol(I ndex))
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(Inde x, gCtrls.ChnVol(I ndex))
LabControl(Inde x).Text = Chr(Inner)
Inner = Inner + 1
Next
UserSwp(5).Name = "LUNG"
UserSwp(5).circ BackColor = Me.BackColor
ANOTHER USAGE
For Index = 1 To 6
gCtrls.ChnVol(I ndex - 1) = gbytEPA(Index)
frmSweep.UserSw p(Index - 1).VolVal = gbytEPA(Index)
Next Index 5 2280
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(By Val sender As System.Object, ByVal e As
System.EventArg s)
with DirectCast(Send er, 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.
Some good points. I printed it out and will wait to see if other ideas are
forthcoming.
Thanks
GalenS
"creator_bo b" <ro************ @hotmail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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(By Val sender As System.Object, ByVal e As System.EventArg s) with DirectCast(Send er, 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.
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.a sp
"Creating Control Arrays in Visual Basic .NET and Visual C# .NET" http://msdn.microsoft.com/library/de...us/dv_vstechar
t/html/vbtchCreatingCo ntrolArraysInVi sualBasicNETVis ualCNET.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.
==============
Very interesting but I still like my method better. I will probably modify
per "Creator_bo b'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.Che cked Then
iCount += 1
End If
End If
Next
GalenS
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.com> wrote in message
news:pY******** ******@TK2MSFTN GXA01.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.a sp "Creating Control Arrays in Visual Basic .NET and Visual C# .NET" http://msdn.microsoft.com/library/de...us/dv_vstechar t/html/vbtchCreatingCo ntrolArraysInVi sualBasicNETVis ualCNET.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. ==============
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 is approx 60 forms with so approx 180 to 240 classes
The back end was and remains S!L Server 2000
|
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.
One of the error was that it wouldn't load a VB6 control.
|
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 enlarged version of that thumb from a file folder of jpgs. Unfortunately VB2005 no longer has a way to make a click event on a particular portion of a larger thumbnail screen. I just need an idea from anyone who has one. I thought of tracking cursor...
|
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;
I created the equivalent in VB:
|
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...
| |
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |