2 Replies - 363 Views - Last Post: 01 May 2012 - 03:15 PM Rate Topic: -----

#1 royalblunts  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-April 12

trying to make a gui, need help with last error

Posted 30 April 2012 - 12:27 PM

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        Int(colorNumber)
        colorNumber = Convert.ToInt32(TextBox1.Text)
        If (colorNumber = 1) Then
            Me.BackColor = Color.Red
        ElseIf (colorNumber = 2) Then
            Me.BackColor = Color.Yellow
        ElseIf (colorNumber() = 3) Then
            Me.BackColor = Color.Green
        ElseIf (colorNumber() > 3) Then
            Me.BackColor = Color.White
        End If

    End Sub


I get an error on "colorNumber" in the line/// colorNumber = Convert.ToInt32(TextBox1.Text) //// It says expression is a value and can't be target of statement. What does that mean? Then how can I change the target?

Is This A Good Question/Topic? 0
  • +

Replies To: trying to make a gui, need help with last error

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,662
  • Joined: 23-August 08

Re: trying to make a gui, need help with last error

Posted 30 April 2012 - 12:57 PM

This is VB.NET code, not C or C++. Moved to VB.NET.
Was This Post Helpful? 0
  • +
  • -

#3 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: trying to make a gui, need help with last error

Posted 01 May 2012 - 03:15 PM

Check line 5 of your code

you are mixing languages. If you want vb.net and you want colornumber to be an integer, then use

dim colornumber as integer



If you want it to be the index af an array called int, that is fine, but it defines the amount of elements in that array. But to change it you should redim your array or if you use indexes between zero and colornumber-1 you should define your algorith differently.

Change line 5 and see what happens.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1