Loading objects at runtime

VB 2008

Page 1 of 1

0 Replies - 1024 Views - Last Post: 16 April 2008 - 12:15 AM Rate Topic: -----

#1 malcnoo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-April 08

Loading objects at runtime

Posted 16 April 2008 - 12:15 AM

Hi, I'm 73 years old and trying to convert from VB6 to VB Net and not finding it easy. I want to load 52 playing cards as labels at run time and then be able to click on them. So far I have got to here and am loading them OK but cannot make the click work - keeps saying need withevent which I do not understand:-
Public Class Form1
	Dim Card1 As New Label()
	Dim label2 As New Label()
	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		card1.Size = New Size(71, 100)
		card1.Location = New Point(200, 200)
		card1.BackColor = Color.Blue
		card1.ForeColor = Color.AliceBlue
		card1.Text = " This has been added at run time"
		'card1.Visible = True


		'PB2.Size = New Size(71, 100)
		'PB2.Location = New Point(300, 300)
		' PB2.BackColor = Color.Red
		'PB2.ForeColor = Color.AliceBlue
		'PB2.Text = " This has been added at run time"
		'PB2.Visible = True
		' Me.Controls.A

	End Sub
	Private Sub Card1_click(ByVal sender As Object, ByVal e As EventArgs) Handles Card1.Click

		MsgBox("You clicked {0}", CType(sender, Control).Name)
	End Sub
End Class

Most grateful if anybody can help make the click work. Also is there any way to load them with an index which was so easy in VB6?

Many thanks


Is This A Good Question/Topic? 0
  • +

Page 1 of 1