Kashish Arora
Kashish Arora

Reputation: 908

How to capitalize Label.text?

I have written a program that detects the pressed key and adds the key value to a label.

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
    Label23.Text = Label23.Text & e.KeyChar
    If Label1.Text = Label23.Text Then
        PictureBox1.Show()
    End If
End Sub

The problem is label1 is uppercase (and I can't make it in small letters) and label23 (to which the value is adding) is lowercase. Is there any way in which I can make the value of label as uppercase or make e.KeyChar to add capital letters to the label?

Upvotes: 3

Views: 5898

Answers (1)

LiamB
LiamB

Reputation: 18586

You need to look at the String.ToUpper() function.

Label23.Text = Label23.Text.ToUpper();

There is also the String.ToLower() method.

Label23.Text = Label23.Text.ToLower();

Upvotes: 5

Related Questions