CType error: Expression is a value and therefore cannot be the target of an assignment.
Posted on 2004-10-30
To convert task to Object this is what I do:
Dim taskOriginal1 as Task = new task()
obj1 = Ctype(taskOriginal1, Object)
Another task is converted to Object:
Dim taskOriginal2 as Task = new task()
obj2 = Ctype(taskOriginal2, Object)
Then I want to make the TaskOriginal1 to refer to taskOriginal2
CType(obj1, task) = CType(obj2, task)
But this statement gives an error: Expression is a value and therefore cannot be the target of an assignment.
If I do this instead:
Dim objTask1 As task = Ctype(obj1, task)
objTask1 = Ctype(obj2, task)
1. Will objTask1 refer to the taskOriginal2?
2. Why does it gives that error?
3. I thought CType returns a reference. Does it mean I can't change the value of an anonymous reference and why?