help with creating a 'nickname' or 'alias'

T

Tarren

Hi:

I am not sure what the code would be to achieve this.

I am looking for a way to give an alias to an object, so I can assign values
to the object regardless of the name.

What is the way to make an object which is just a shortcut to another
object, so when I am referring to the shortcut, it is really altering the
original object?

something like a myAlias but I am not sure how to declare it

If something then
myAlias = dataGRID1
elseif something else
myAlias = dataGRID2
else
myAlias = dataGRID3
end if

<ADO functions to create dataset as oDS>

myAlias.DataSource = oDS
myAlias.Databind()

I want to not have to write the ADO functions three times. I need to
determine the datagrid up front, and not after the ADO functions for logical
reasons within the code.

VB .NET or C# example would be fine. Hopefully VB .NET given the newsgroup
:)

Thanks!
 
C

Chris, Master of All Things Insignificant

If your problem is as simple as I'm think it is, just do this:

Dim myAlias as DataGrid
If something then
myAlias = dataGRID1
elseif something else
myAlias = dataGRID2
else
myAlias = dataGRID3
end if

myAlias.DataSource = oDS
myAlias.Databind()

Notice how I don't use "new" to declare the variable. I'm not creating an
object, just a reference point to other objects.

Hope it helps
Chris
 
T

Tarren

Thanks! Works perfectly. :)


Chris said:
If your problem is as simple as I'm think it is, just do this:

Dim myAlias as DataGrid
If something then
myAlias = dataGRID1
elseif something else
myAlias = dataGRID2
else
myAlias = dataGRID3
end if

myAlias.DataSource = oDS
myAlias.Databind()

Notice how I don't use "new" to declare the variable. I'm not creating an
object, just a reference point to other objects.

Hope it helps
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top