Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to change Label text ToUpper?

Posted on 2004-11-19
7
Medium Priority
?
664 Views
Last Modified: 2010-05-18
I have a few labels on my vb.net form. When I load a record sometimes the text is all lowercase.
How can I make the text change to all Upper case or ProperCase when the text changes?

I tried the following but it doesn't seem to work...

    Private Sub lblFirstName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblFirstName.TextChanged
        lblFirstName.Text.ToUpper()
        lblLastName.Text.ToUpper()
        lblStreetName.Text.ToUpper()
        lblCity.Text.ToUpper()
        lblState.Text.ToUpper()
    End Sub

0
Comment
Question by:Matrix1000
  • 4
  • 2
7 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12629084
dim s as string = "iouri"
lblFirstName.Text = s.ToUpper()
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12629088
HI there,
do not use the TextChanged event to do that. That is definitely gonna take more resource. Rather what you can do is, just before you display the data in the labels , change the case.

lblFirstName.Text = UCase(YourDataString)

-Baan
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12629155
Is not it the same that I wrote?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12629183
it is.. but I replied 1 min later.. unfortunately... lol
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12629253
If you want to keep what u are doing... do this

    Private Sub lblFirstName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblFirstName.TextChanged
        lblFirstName.Text=lblFirstName.Text.ToUpper()
        lblLastName.Text=lblLastName.Text.ToUpper()
        lblStreetName.Text=lblStreetName.Text.ToUpper()
        lblCity.Text=lblCity.Text.ToUpper()
        lblState.Text=lblState.Text.ToUpper()
    End Sub

-Baan
0
 
LVL 1

Author Comment

by:Matrix1000
ID: 12629321
-Baan

This is my database query... how would I add that....what would be "YourDataString" ?

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        ' Get data from selected row in ListBox
        ' Because I don't know which row of the original DataView this is
        ' it is probably easier to do a refined search which (hopefully) will only
        ' throw up one possible row

        ' First make sure the DataView will search the address column
        dvSocSecNo.Sort = "SocSecNo"
        ' Create a DataRowView and make it find the datarow that contains the address
        Dim ChosenRow() As DataRowView = dvSocSecNo.FindRows(Trim(ListBox1.SelectedItem))
        If ChosenRow.Length > 0 Then ' if a match found (and it should be!)
            Dim DRV As DataRowView
            ' Display data from other columns in textboxes
            For Each DRV In ChosenRow
                Me.txtSearch.Text = DRV("SocSecNo").ToString
                Me.lblFirstName.Text = DRV("FirstName").ToString
                Me.lblLastName.Text = DRV("LastName").ToString
                'Me.lblStreetNumber.Text = DRV("StreetNumber").ToString
                Me.lblStreetName.Text = DRV("Address1").ToString
                Me.lblCity.Text = DRV("City").ToString
                Me.lblState.Text = DRV("State").ToString
                Me.lblZip.Text = DRV("Zip").ToString

            Next
        Else
            MessageBox.Show("Data not found")
        End If
End Sub
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 2000 total points
ID: 12629353
Change this part...

            For Each DRV In ChosenRow
                Me.txtSearch.Text = DRV("SocSecNo").ToString
                Me.lblFirstName.Text = UCase(DRV("FirstName").ToString)   'Add UCase() to all of them
                Me.lblLastName.Text = UCase(DRV("LastName").ToString)
                'Me.lblStreetNumber.Text = UCase(DRV("StreetNumber").ToString)
                Me.lblStreetName.Text = UCase(DRV("Address1").ToString)
                Me.lblCity.Text = UCase(DRV("City").ToString)
                Me.lblState.Text = UCase(DRV("State").ToString)
                Me.lblZip.Text = DRV("Zip").ToString

            Next
-Baan
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question