473,463 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using VB 2010, I need to access a label's Tag data (in this case a number) in a label

2
I will have ten labels, each will have a Tag property set to 1 through 10. In each label's click event, I want to be able to access the Tag property without referring directly to the Label's Name. I have tried Me. My. sender, etc. but unable to get something workable. Thank you
Dec 13 '13 #1
1 1767
Frinavale
9,735 Expert Mod 8TB
You mentioned that you have implemented a method that handles the Click Event for all the 10 labels that you want to work with.

This means that you should have a method that looks something like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub labels_Click(sender As Object, e As System.EventArgs) Handles label1.Click, label2.Click,  label3.Click ,label4.Click,  label5.Click, label6.Click, label7.Click, label8.Click, label9.Click, label10.Click
  2.  
  3. End Sub
The sender parameter is the control that fired the event...in other words, it is the Label that was clicked.

From there you should be able to retrieve the content of the label, parse it into an Integer and do your logic.

Expand|Select|Wrap|Line Numbers
  1. Private Sub labels_Click(sender As Object, e As System.EventArgs) Handles label1.Click, label2.Click, label3.Click, label4.Click,  label5.Click, label6.Click, label7.Click, label8.Click, label9.Click, label10.Click
  2.  
  3.   Dim theLabelClicked As Label = DirectCast(sender, Label)
  4.   Dim theInteger As Integer
  5.   Integer.TryParse(theLabelClicked.Text, theInteger)
  6.  
  7.   If theInteger > 0 And theInteger <= 10
  8.     '...Do Processing Of Stuff...
  9.   End If
  10. End Sub
-Frinny
Dec 17 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
1
by: mhnazly | last post by:
i'm trying to read data from SQL Server database using data reader and assigned it to a label in my asp.net web application. but when the button is clicked, nothing appears. please help, thanks. ...
2
by: Marcus | last post by:
(Appologies if this group isn't the best place for this post) Is it possible to use DAO 3.6 to access binary data (varbinary(max)) in Sql Server 2005? I have images and sound in a Sql 2005 DB...
5
by: shapper | last post by:
Hello, In this moment I am creating all my aspx pages on my vb.code at runtime. It seems nonsense to have .aspx and .aspx.vb files in my projects. I am considering creating my pages on the...
4
by: Ben | last post by:
Hi, i have some problem to access from code-behind a label nested into a CreateWizard control. I use a html-table for align purpose only. I try to change the text property of the label with...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: nfontaine | last post by:
I am creating a database in Access 2002. I need to create a computer generated case number that starts with the year and is in the form YY-nnnnnn (6 digit number) that increments by 1. I am not a...
1
by: denzelw78 | last post by:
Hello! i am programming in vb 2010, and i tried to connect vb 2010 with access 2007 base with this code: Dim dbBaza As String Dim putanja As String putanja =...
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...
0
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.