Mohamed Amer Mohamed Amer - 14 days ago 4
Vb.net Question

VB.NET Expression is a value and therefore cannot be the target of an assignment

I am trying to write a code that solves quadratics using VB

why this is showing error:


Error 1 Expression is a value and therefore cannot be the target of an
assignment


Module Module1

Sub Main()

Dim A, B, C As Integer

Console.WriteLine("Quadratic Equation calculator")
Console.WriteLine(" AX^2 + BX + C")
Console.WriteLine("Enter A")
Console.Read() = A
Console.WriteLine("Enter B")
Console.Read() = B
Console.WriteLine("Enter C")
Console.Read() = C

'ax^2 + bx + c = 0
'enter a,b and c
'set ac as variable
'set b as variable
'find number that multiplies for ac and adds for b
'put them in (X+ )(x+ )

End Sub

End Module

Answer
Console.Read() = A

So, Console.Read() is procedure that reads value from console and return it. So you can't assign anything to it. But! But you can assign the return value to something. In this case it's A or B or C. The correct answer will be:

A = Console.Read()

And so on.

Comments