Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27192

[SOLVED]There has to be a shortcut..

$
0
0
Name:  Untitled.png
Views: 112
Size:  33.3 KB

As you can see, I have a form with 48 different colors/48 labels with a different background color.

Whenever a label is pressed, the color is stored inside a variable and when the user click on "Save", the font changes to said color.

My problem is, i would have to write label_color(label1), label_color(label2), label_color(label3) etc.. for each labels.

Is there a way i could write something like : label_color(me.label) instead to save time?

Code:


Public Class Colors

    Dim color As Color = Nothing

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Form_Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Clean_Text.txtBox.ForeColor = color
        Form_Close()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        label_color(Label1)
    End Sub

    Private Sub label_color(ByVal color_label As Label)
        color = color_label.BackColor
    End Sub

    Private Sub Form_Close()
        Me.Close()
    End Sub

End Class

Attached Images
 

Viewing all articles
Browse latest Browse all 27192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>