FORUMS

Help with visual basic

188 posts
Thanks Meter: 23
 
By fujirio, Senior Member on 6th February 2014, 02:50 AM
Post Reply Subscribe to Thread Email Thread
can some one help me find the errors on this program

Public Class DemoUpper

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const strLowerCase As String = "visual basic"
strLowerCase = strLowerCase.ToUpper
txtOutput.Text = strLowerCase
End Sub
End Class
 
 
6th February 2014, 02:56 AM |#2  
veeman's Avatar
Senior Member
Flag Minnesota
Thanks Meter: 1,518
 
More
Try using the CODE tags around the text so it gets formatted correctly. Or paste it here and post the link http://pastebin.com/
6th February 2014, 03:02 AM |#3  
OP Senior Member
Thanks Meter: 23
 
More
Quote:
Originally Posted by veeman

Try using the CODE tags around the text so it gets formatted correctly. Or paste it here and post the link http://pastebin.com/

http://pastebin.com/0Qw1kKJ0#

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Const strLowerCase As String = "visual basic"
        strLowerCase = strLowerCase.ToUpper
        txtOutput.Text = strLowerCase
    End Sub
      End Class
7th February 2014, 02:39 AM |#4  
kibermaster's Avatar
Junior Member
Flag Moscow
Thanks Meter: 1
 
More
Quote:
Originally Posted by fujirio

http://pastebin.com/0Qw1kKJ0#

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Const strLowerCase As String = "visual basic"
        strLowerCase = strLowerCase.ToUpper
        txtOutput.Text = strLowerCase
    End Sub
      End Class

You've declared "strLowerCase" as constant, so you can't assign a value to it, you can only read it. So, the working code should look like this:

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Dim strLowerCase1 as string
        Const strLowerCase As String = "visual basic"
        strLowerCase1 = strLowerCase.ToUpper
        txtOutput.Text = strLowerCase1
    End Sub
      End Class
But also you can make it shorter like this:

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Const strLowerCase As String = "visual basic"
        txtOutput.Text = strLowerCase.ToUpper
    End Sub
      End Class
8th February 2014, 11:58 PM |#5  
OP Senior Member
Thanks Meter: 23
 
More
Thumbs up
Quote:
Originally Posted by kibermaster

You've declared "strLowerCase" as constant, so you can't assign a value to it, you can only read it. So, the working code should look like this:

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Dim strLowerCase1 as string
        Const strLowerCase As String = "visual basic"
        strLowerCase1 = strLowerCase.ToUpper
        txtOutput.Text = strLowerCase1
    End Sub
      End Class
But also you can make it shorter like this:

Code:
Public Class DemoUpper

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles   btnDisplay.Click
        Const strLowerCase As String = "visual basic"
        txtOutput.Text = strLowerCase.ToUpper
    End Sub
      End Class


wow thank you so much
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools
Display Modes