Need to edge out the competition for your dream job? Train for certifications today.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lbl As Label
Dim ctl As Control
Dim ctlName As String
For i As Integer = 1 To 5
ctlName = "Label" & i
ctl = GetControlByName(ctlName)
If Not IsNothing(ctl) AndAlso TypeOf ctl Is Label Then
lbl = CType(ctl, Label)
lbl.Text = "I'm Label #" & i
Private Function GetControlByName(ByVal ctlName As String) As Control
Dim matches() As Control = Me.Controls.Find(ctlName, True)
If matches.Length > 0 Then
Private Sub lbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click, Label2.Click, Label3.Click, Label4.Click, Label5.Click
Dim lbl As Label = CType(sender, Label)
MessageBox.Show("Hello from " & lbl.Name)
Open in new window
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.