473,624 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cant assign variable values to property in Class file

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.C olor

plz help me out

Thanks in advance

Dec 11 '06 #1
4 2500
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=TDCOLO R1 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.co ma écrit dans le message de news:
11************* ********@j44g20 00...legro ups.com...
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.C olor

plz help me out

Thanks in advance

Dec 11 '06 #2
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
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=TDCOLO R1 (both being Color object)
vartable &= TDCOLOR1.ToStri ng vartable being a string and converting
TDCOLOR1 to a string (but you would store multiple colors without any
separator ?)
vartable(i)=TDC OLOR 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.co ma écrit dans le message de news:
11************* ********@79g200 0c...legrou ps.com...
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
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.ToS tring("x2") _
& colorTD.Green.T oString("x2") _
& colorTD.Blue.To String("x2")
Return "<td bgcolor='#" & sColor & "'>"
End Function

HTH,
Phill W.
Dec 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
4322
by: Rim | last post by:
Hi, I have been thinking about how to overload the assign operation '='. In many cases, I wanted to provide users of my packages a natural interface to the extended built-in types I created for them, but the assign operator is always forcing them to "type cast" or coerce the result when they do a simple assign for the purpose of setting the value of a variable. Borrowing an example from this newgroup, the second assignment below ereases...
16
25404
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
10
3474
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get { return dbConnectionString;
4
1283
by: darrel | last post by:
Karl has helped me in the past in regards to communicating between controls and pages: http://www.openmymind.net/communication/index.html#3.1 I ended up going down the interfaces path and actually got that working fairly well, but, then, in the end, decided that was overkill and that it would perhaps make more sense to start over using a much more simpler communication between pages.
2
1487
by: Microsoft | last post by:
I have a variable that will equal something like this.. result= joe,200,male,sales I know if I save the values to a text file and open it in EXCEL it shows up in a nice colum format (csv) Is there any way to simulate this on a vb.net form? So that I don't have to save the values to a csv file and open it separately?
1
1332
by: Joe Cool | last post by:
Using VB.NET 2005. I will not go into detail on a problem I can't figure out, but I will describe it simple terms that should convey the underlying issue. I have a class called ClassA. It has two properties, Property1 and Property2. Both properties are string datatypes. This class is a member of a class library. I have some code in an application that imports the class library that
6
2259
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1") txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2") ..... txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10") ------code ------- Dim field As String = "Q"
8
12613
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below. The code below draws an error as indicated. Surely there has to be a better way than to make xxx a session variable? Thanks
6
4093
by: Don Lancaster | last post by:
I need to progrmatically do this inside a loop this.fh03.value = fixFloat (Harms, numPoints) ; with the numbers changing per an index. If I try curHvals = "03" ; // (derived from index to provide leading zero)
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.