473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Converting String into Object

Hi There,
Can any one suggest me how to convert the string into object in VB.net.
If you are familier with javascript you can use.

var i = 1
eval("textbox" + i).value = "Hello World"

What is the equivalent of this in VB.net

Cheers..Rajesh
Nov 20 '05 #1
5 32087
Hello,

"Rajesh Kr Shukla" <rk******@india.com> schrieb:
Can any one suggest me how to convert the string into
object in VB.net. If you are familier with javascript you
can use.

var i = 1
eval("textbox" + i).value = "Hello World"

What is the equivalent of this in VB.net


\\\
Private Function FindControl( _
ByVal ControlName As String, _
ByVal CurrentControl As Control _
) As Control
Dim ctr As Control
For Each ctr In CurrentControl.Controls
If ctr.Name = ControlName Then
Return ctr
Else
ctr = FindControl(ControlName, ctr)
If Not ctr Is Nothing Then
Return ctr
End If
End If
Next ctr
End Function
///

Usage:

\\\
DirectCast(FindControl("btnBla", Me), Button).Enabled = False
///

Notice that the procedure listed above is "slow", if you have to access a
lot of controls by name very often, you should store references to them in a
'Hashtable' object. You can use the name of the control as key.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Hi,
Thanks for you reply, but my problem is different. Here I have just
taken the example of TextBox, but in my example I have got a function
which receives parameter as an Object (User defined object not the
controls on form).

That Object name I am creating in runtime.
Cheers..Rajesh



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Hi Rajesh,

To find an object, 'someone' must know about the object. To find an object
within a set, 'someone' must have a set of references.

If you know in advance that you will need this facility with certain
objects, you can use a class, derived from HashTable, with which you register
those objects when they are created. It could be in a Module for convenience.

If this doesn't address what you're after, can you give us some more
details?

Regards,
Fergus
Nov 20 '05 #4
Hi Rajesh,

Basically: No.

Object names are not kept at compilation, they are obliterated. This means
you cannot reference an object by name.

Why do you want to do this? Perhaps we can suggest a better way.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Rajesh Shukla" <rk******@india.com> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
: Hi,
: Thanks for you reply, but my problem is different. Here I have just
: taken the example of TextBox, but in my example I have got a function
: which receives parameter as an Object (User defined object not the
: controls on form).
:
: That Object name I am creating in runtime.
:
:
: Cheers..Rajesh
:
:
:
:
:
:
:
: *** Sent via Developersdex http://www.developersdex.com ***
: Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
Hello,

"Rajesh Shukla" <rk******@india.com> schrieb:
Thanks for you reply, but my problem is different. Here
I have just taken the example of TextBox, but in my
example I have got a function which receives parameter as
an Object (User defined object not the controls on form).


Sorry, I don't understand what you want to do. You may want to have a look
at the 'Activator.CreateInstance' method.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6

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

Similar topics

1
by: Ajay | last post by:
hi! how do i go about converting a Python object or tuple to a string. i am currently doing import cPickle as pickle str = pickle.dumps(obj) is thate efficient? is that the best way to do...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
3
by: Parvesh | last post by:
hi, I am using a webservice which Returns the Result in an XML string, The XML response i get i svery cumbersome to parse, But if i could convert it to the Corresponding Class using the...
5
by: Testguy | last post by:
Hi, I was wondering if one the smart people that frequent this group could give me a hand with a small program I am attempting to debug. I am not a highly experienced developer, but can...
3
by: Wallace | last post by:
Hai, Can anyone tell how to convert an object into string? Please help me.... urgent.. Thanx in advance...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
9
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived)...
1
by: Kevin S Gallagher | last post by:
I found this code (pretty sure it was from a MVP) for converting a string variable to a form object which works fine within a form. Take the code and place it into a code module and it fails on the...
2
by: CoreyWhite | last post by:
Problem: You have numbers in string format, but you need to convert them to a numeric type, such as an int or float. Solution: You can do this with the standard library functions. The...
3
by: Dhananjay | last post by:
Hi All, I am facing problem when i am converting C#.net code(Delegate concept) into vb.net. I am unable to do that . Can someone help me to solve the problem. I am providing my C#.net code. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.