Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2004, 07:09 PM
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tonjaw
Default variable

hi,

is it possible in VB.NET variable contains variable.
sorry for my english, here i try to give u an example.
i have 2 classes called clsMsSQL and clsOracle. i
wanna make an object from one of it within a function.

function makeObject(byval strClass as string) as
object
   ' the following strClass should represent
   ' either "clsMsSQL" or "clsOracle"

   dim objDB as new strClass
   return objDB
end function


this function is called like this...

dim objDB as object = makeObject("clsMsSQL")


how should i write the function?
i can be done in PHP but i guess there must be a way
to do it in VB.NET as well.



thanx in advance

_____________________
Dominus Tecum
 
Old October 18th, 2004, 10:36 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Write a static function which will take an argument which says which object to return then return object of that class, to return that you can define a Interface and implement "clsMsSQL and clsOracle" in these classes.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 23rd, 2004, 09:32 PM
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tonjaw
Default

that's it. thanx pradeep, really appreciate it :)

btw, i have another problem. is it possible to declare a variable which has name based on iteration?
this can be done in PHP. here a simpe php script:

Code:
For($i=1; $i<4; $i++){
       ${"strRead{$i}"} = ${"chkRead{$i}"}
}
i'm pretty sure that .net has its way to do it. i cannot use an array because these variables will be used in web form control.

thanx

_____________________
Dominus Tecum
 
Old October 24th, 2004, 05:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Cross post. Please see here: http://p2p.wrox.com/topic.asp?TOPIC_ID=21154 for replies.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Split into fractions by Curve (Track 7 from the album: Doppelganger) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Object variable or With block variable not set tparrish Pro VB Databases 1 May 25th, 2005 02:08 PM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.