By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,880 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,880 IT Pros & Developers. It's quick & easy.

cant assign variable values to property in Class file

P: n/a
Avi
Hi

I am creating web application in which i want to assign by
default values to the property which i had created my own. In that one
of the property is of type color and i am unable to assign any value to
that color type property..

my code is

Dim Col1Color as String

vartable="------"
vartable&= TDCOLOR1

i got error:- & operator not defined for System.Object and
syste.Drawing.Color

plz help me out

Thanks in advance

Dec 11 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Basically vartable looks like an object while TDCOLOR1 is a
System.Drawing.Color object and &= is the string concatenation operator. You
can't string concatenate an object and a Color object.

I would declare vartable as a color and would use Vartable=TDCOLOR1 but I'm
not sure this is what you are trying to do (vartable="-----" wouldn't work
any more but why are you doing this if vartable ios really supposed ton be a
color object ?)

--
Patrice

"Avi" <st******************@gmail.coma écrit dans le message de news:
11*********************@j44g2000cwa.googlegroups.c om...
Hi

I am creating web application in which i want to assign by
default values to the property which i had created my own. In that one
of the property is of type color and i am unable to assign any value to
that color type property..

my code is

Dim Col1Color as String

vartable="------"
vartable&= TDCOLOR1

i got error:- & operator not defined for System.Object and
syste.Drawing.Color

plz help me out

Thanks in advance

Dec 11 '06 #2

P: n/a
Avi
Hi Patrice,

what i m doing is.

I hav a one class file in which i had created some property and
assigning some default values to those property. in the NEW() function
OK. Again in this NEW() function i had created one dynamic table and
those property are related to that table.
in the Page Load() funtion of .aspx file i want to give some new
values to those property

now problem is that

When application starts it call first NEW( ) function in which table
with default values get generated and now in Page Laod( ) function i
want to assign new values in place of those default values. which i
cant. so is there any way to call the NEW( ) from Page_Load( )
.......

Dec 12 '06 #3

P: n/a
I meant rather what is the final non technical goal. For example is vartable
supposed to store a color object ? Is this a list of colors as the
concatenation seems to imply ? etc...

For now :
- vartable is an object (but you assign first a string to it ?)
- TDCOLOR1 is a color object
- you try to string concatenate these two objects ?

So you can't string concatenate those two objects, hthis is as if you would
try to add a string and a date. It doesn't make sense.

So you have multiple solutions such as :
vartable=TDCOLOR1 (both being Color object)
vartable &= TDCOLOR1.ToString vartable being a string and converting
TDCOLOR1 to a string (but you would store multiple colors without any
separator ?)
vartable(i)=TDCOLOR vartable being an array of colors

For now the code exceprt doesn't make clear what your intent is :
- you provide the declaration for Col1Color but it is not used in your code
- we don"t know how vartbale TDCOLOR1 are declared though it is used in your
code
- from the message you try to string concatenate a color and an object (but
it looks weird you first put ----- in vartbale etc...)
etc...

--
Patrice

"Avi" <st******************@gmail.coma écrit dans le message de news:
11*********************@79g2000cws.googlegroups.co m...
Hi Patrice,

what i m doing is.

I hav a one class file in which i had created some property and
assigning some default values to those property. in the NEW() function
OK. Again in this NEW() function i had created one dynamic table and
those property are related to that table.
in the Page Load() funtion of .aspx file i want to give some new
values to those property

now problem is that

When application starts it call first NEW( ) function in which table
with default values get generated and now in Page Laod( ) function i
want to assign new values in place of those default values. which i
cant. so is there any way to call the NEW( ) from Page_Load( )
......

Dec 12 '06 #4

P: n/a
Avi wrote:
I hav a one class file in which i had created some property and
assigning some default values to those property. in the NEW() function
OK. Again in this NEW() function i had created one dynamic table and
those property are related to that table.
in the Page Load() funtion of .aspx file i want to give some new
values to those property
Class X
' ?Inherits Y

Public Sub New()
End Sub

Public Property TDBackground() as Color
Get
Return colorTD
End Get
Set( Value as Color )
colorTD = Value
End Set
End Property

Private colorTD as Color = Color.Black

End Class

Private oX As New X()

Sub Page_Load( ...
oX.TDBackground = Color.Green
End Sub
When application starts it call first NEW( ) function in which table
with default values get generated and now in Page Laod( ) function i
want to assign new values in place of those default values. which i
cant. so is there any way to call the NEW( ) from Page_Load( )
No, but you could either create a "reload" method can you call from
New() and elsewhere or, perhaps better, add a "Render" method that
generates the HTML based on the properties you've set.

Public Function Render() As String
' I'm guessing at what this needs to do ...
' I think the "x2" will work - haven't tried it
Dim sColor as String _
= colorTD.Red.ToString("x2") _
& colorTD.Green.ToString("x2") _
& colorTD.Blue.ToString("x2")
Return "<td bgcolor='#" & sColor & "'>"
End Function

HTH,
Phill W.
Dec 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.