473,506 Members | 17,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Index


Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a unique index, how is done in vb.net? bellow is the code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Dim i As Integer =
Dim myPic(10) as pictureBo
Dim yAxis As Integer =
For i = 0 To

MyPic(i) = New PictureBo

MyPic(i).Width = 13
MyPic(i).Height = 4

'Mypic(i).Font = New Font("Verdana", 9.75!, FontStyle.Regular

MyPic(i).BackColor = Drawing.Color.Blac
MyPic(i).SizeMode = PictureBoxSizeMode.StretchImag
MyPic(i).Location = New System.Drawing.Point(Left, Top
MyPic(i).Name = "Pic" &
'Mypic(i).Text = rst("ProductName").Valu
MyPic(i).Location = New Point(660, yAxis
MyPic(i).Cursor = Cursors.Han
MyPic(i).BringToFront(
Me.Controls.Add(MyPic(i)
MyPic(i).Image = ImageList1.Images.Item(i

AddHandler MyPic(i).Click, AddressOf mypic_clic
yAxis = yAxis + 5 + MyPic(i).Heigh
Nex
End Su

NEED THE CODE PLEAS

THANX IN ADVANCE
Nov 20 '05 #1
17 1568
In article <2F**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...

Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button

had a unique index, how is done in vb.net?

1) Create a form-level ArrayList.
2) After creating the button, add it to the ArrayList at the specified
index. Example:

myList.Insert(i, myNewButton)

3) In the click event handler, the "sender" object will be the button
that was pushed. Use the "IndexOf" method to find out which button was
pushed:

Dim index As Integer = myList.IndexOf(sender)

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
* "=?Utf-8?B?V2lsbA==?=" <an*******@discussions.microsoft.com> scripsit:
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button
had a unique index, how is done in vb.net? bellow is the code:


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

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
In article <5F**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...
Great example one question, could you please give me an example (code) on how to create a form-level ArrayList ?
thanx


Just define it outside of all of your methods:

Public Class MyForm
Inherits Form

Private myList As ArrayList = new ArrayList()

...
--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #4
Cor
Hi Will,

I do not understand this, this is almost the sample I gave you and the code
is VB.net code how did you do this in VB6?

Cor
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer = 0
Dim myPic(10) as pictureBox
Dim yAxis As Integer = 9
For i = 0 To 1
MyPic(i) = New PictureBox

MyPic(i).Width = 130
MyPic(i).Height = 40

'Mypic(i).Font = New Font("Verdana", 9.75!, FontStyle.Regular)

MyPic(i).BackColor = Drawing.Color.Black
MyPic(i).SizeMode = PictureBoxSizeMode.StretchImage
MyPic(i).Location = New System.Drawing.Point(Left, Top)
MyPic(i).Name = "Pic" & i
'Mypic(i).Text = rst("ProductName").Value
MyPic(i).Location = New Point(660, yAxis)
MyPic(i).Cursor = Cursors.Hand
MyPic(i).BringToFront()
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
yAxis = yAxis + 5 + MyPic(i).Height
Next
End Sub

NEED THE CODE PLEASE

THANX IN ADVANCE

Nov 20 '05 #5
Cor
Hi Herfried,

This is a message about a VB.net sample I gave can this be done in VB6?

Cor
Nov 20 '05 #6
Cor
Hi Patrick,

This is a message about a VB.net sample I gave, can this be done in VB6?

In my sample is no need for an Arraylist I use that almost always, except
when the array is fixed as is in this sample.

Cor
Nov 20 '05 #7
Cor
Hi Patrick,

This is the correct answer by the way, accoording to my sample, although it
is an array
Just define it outside of all of your methods:


But I did wanted to keep the sample nice and putted it inside the procedure.
Using directcast with the sender in the event, that I also supported (it is
disapeared now), it is not really needed, but when you do more with it, it
can be the answer.

And when the array really becomes dynamic using an arraylist is of course
better.

Cor
Nov 20 '05 #8
Cor,

* "Cor" <no*@non.com> scripsit:
This is a message about a VB.net sample I gave can this be done in VB6?


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

:-(

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

The poster tells that he has created this in VB6 while it is code I
supported to him on 26-1.
(You should have seen it before because I have contributed this so much,
because I find it a real nice example because it is so simple).

And now I am curious if this code can be done in VB6 because you are
answering that.

This is the start of the original thread
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a

unique index, how >is done in vb.net? bellow is the code:

I think that code cannot be done in VB6.

Or am I crazy?

Cor
Nov 20 '05 #10
Cor,

* "Cor" <no*@non.com> scripsit:
This is the start of the original thread
Hey guys, i have 5 buttons created on runtime, in vb 6.0, each button had a

unique index, how >is done in vb.net? bellow is the code:

I think that code cannot be done in VB6.


Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.

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

Look at the code he said he made this in VB6.
Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?

Cor
Nov 20 '05 #12
Cor,

* "Cor" <no*@non.com> scripsit:
Look at the code he said he made this in VB6.
Yes, that can be done in VB6 by using a control array. You can
load/unload buttons to/from the array by using 'Load' and 'Unload' in
VB6.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?


Yes, something similar was possible with VB6. You could create a
control array and create a common handler for the array. The shared
handler had an index parameter which contained the index of the control
in the control array firing the event.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #13
Cor
The OP stated that he has written this code with VB6 that is my question.
I believe that something simular was posible exactly this code on VB6
(knowing me you know of course that I tried it already before I wrote this,
but did I see something wrong?)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Controls.Add(MyPic(i))
MyPic(i).Image = ImageList1.Images.Item(i)
AddHandler MyPic(i).Click, AddressOf mypic_click
Next
End Sub

Are you sure of that, than VB6 could more than I thought?


Yes, something similar was possible with VB6. You could create a
control array and create a common handler for the array. The shared
handler had an index parameter which contained the index of the control
in the control array firing the event.

Nov 20 '05 #14
* "Cor" <no*@non.com> scripsit:
The OP stated that he has written this code with VB6 that is my question.


Sorry, I misread. The code the OP posted won't run on VB6.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #15
Cor
No problem...

:-)

I could copy it,

:-))

Cor
Nov 20 '05 #16
Cor,

* "Cor" <no*@non.com> scripsit:
No problem...

:-)

I could copy it,


What?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #17
Cor
No proplem
What?


:-))
Nov 20 '05 #18

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

Similar topics

3
6073
by: Jofio | last post by:
Hello, I am a newbie in PHP and I am enthusiastically trying out things. I've just replaced my index.html ( file with index.php
9
2125
by: kosh | last post by:
I was wondering if there is or there could be some way to pass a generator an optional starting index so that if it supported that slicing could be made more efficient. Right now if you do use a...
2
10307
by: skura | last post by:
I am trying to understand how the data in sql server is stored and also regarding fill factor and page splitting. 1) My first question what is the difference between Index pages and Data pages....
6
4446
by: Anita | last post by:
I have just tested 3 queries using QA. The complete test information : ------ CREATE TABLE agls1 ( fyear char(4) NULL , fprefix char(3) NULL , fvcno char(20) NULL , fdate datetime NULL ,...
8
4824
by: Andr? Queiroz | last post by:
Hi, I have a table with 10M records and col A has a index created on it. The data on that table has the same value for col A on all 10M records. After that I insert diferent values for that column...
14
5385
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
4
10637
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
2
5092
by: bobby_b_ | last post by:
I have a table where fields 1 and 2 make up the primary key. Because of this, I have a unique composite index on fields 1 and 2 (as required by DB2). Now my question is: Fields 1 and 2 are also...
85
4223
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
8
5543
by: shira | last post by:
I have done a fair bit of searching, but haven't yet been able to find an explanation as to why one would set "ignore nulls" to "yes" when creating an index. I understand what it does (I think),...
0
7105
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...
0
7308
Oralloy
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,...
0
7371
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...
0
5617
agi2029
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,...
1
5037
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...
0
3188
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...
0
1534
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 ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
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...

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.