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

Home Posts Topics Members FAQ

Ctype

AXH
Hi All,

I have to following problem.
Is it possible type convert a stringvalue to a type value.
Please look below for the example
dim regvalue as string= "123456"
dim regtype as string = "String"

private function GetValue as object
return ctype(regvalue,?????????)
end function

Thanks,
AXH
Aug 15 '06 #1
4 1910
AXH wrote:
Hi All,

I have to following problem.
Is it possible type convert a stringvalue to a type value.
Please look below for the example
dim regvalue as string= "123456"
dim regtype as string = "String"

private function GetValue as object
return ctype(regvalue,?????????)
end function

Thanks,
AXH

I might not have this exact as I don't have my compiler here but it's
something like:

return ctype(regvalue,Type.GetType(regtype))

of course in your example this won't do much since your function is
returning a type object.
Aug 15 '06 #2
AXH

"Chris" <no@spam.comwrote in message
news:eY*************@TK2MSFTNGP05.phx.gbl...
AXH wrote:
>Hi All,

I have to following problem.
Is it possible type convert a stringvalue to a type value.
Please look below for the example
dim regvalue as string= "123456"
dim regtype as string = "String"

private function GetValue as object
return ctype(regvalue,?????????)
end function

Thanks,
AXH

I might not have this exact as I don't have my compiler here but it's
something like:

return ctype(regvalue,Type.GetType(regtype))

of course in your example this won't do much since your function is
returning a type object.

The above code isn't working oke. I will het an error.

Anyone suggestions !!

Thanks
Aug 15 '06 #3
AXH,
It sounds like you want to use Convert.ChangeType.

| dim regvalue as string= "123456"
dim regtype as string = "System.String"
|
| private function GetValue as object
Return Convert.ChangeType(regvalue, Type.GetType(regtype))
| end function

NOTE: regtype needs to be one of the types listed in System.TypeCode,
qualified with its namespace (such as System.String & System.Int32)

Alternatively you could simply use the overload that accepted
System.TypeCode or use GetType(String) & GetType(Integer)...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"AXH" <ax*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
| Hi All,
|
| I have to following problem.
| Is it possible type convert a stringvalue to a type value.
| Please look below for the example
|
|
| dim regvalue as string= "123456"
| dim regtype as string = "String"
|
| private function GetValue as object
| return ctype(regvalue,?????????)
| end function
|
| Thanks,
| AXH
|
|
Aug 15 '06 #4
AXH,

A string is a type.

You can set a string in an object
dim myObject as Object = CType("12345",Object)

Althoug a little bit out of sence because
dim myObject as Object = "12345" works impliciet

I hope this helps,

Cor
"AXH" <ax*******@hotmail.comschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi All,

I have to following problem.
Is it possible type convert a stringvalue to a type value.
Please look below for the example
dim regvalue as string= "123456"
dim regtype as string = "String"

private function GetValue as object
return ctype(regvalue,?????????)
end function

Thanks,
AXH

Aug 16 '06 #5

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

Similar topics

4
6553
by: Joeri | last post by:
Hi, I'm struggling with this issue, maybe someone has already solved ik before. Here's the problem I Have : clsA witch is a base class clsB inherits from clsA clsC inherits from clsA clsD...
1
1787
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
10
2287
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
4
3814
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is...
6
10814
by: Ot | last post by:
I apparently have a bit to learn about Casting and Conversion. I have been thinking of them as the same but a discussion in another thread leads me to believe that this is wrong thinking. I...
8
7338
by: John A Grandy | last post by:
could someone please discuss the pros and cons of CType(MyDouble,Decimal) versus Convert.ToDecimal(MyDouble) .... and other such conversions ...
16
298
by: Craig Buchanan | last post by:
If I am trying to cast an object to one of its decendants, will the decendants' default constructor (New sub) fire? Thanks, Craig
7
2703
by: Brian Henry | last post by:
is there any speed diffrences between doing Ctype or directcast? I know about the inherite diffrences, but process usage time wise, does one take up more cycles then the other? thanks
3
4555
by: Charles Law | last post by:
I have the following lines Dim t As Type = GetType(MyType) Dim serialiser As New XmlSerializer(t) I want to be able to do the following with a FileStream fs Dim instance As MyType ...
3
1783
by: Arpan | last post by:
The syntax of the function CType, as stated in the .NET 2 SDK Documentation, is CType(expression, typename) The Documentation also states that CType is compiled inline which means that the...
0
7158
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...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
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...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
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...
0
3232
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...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
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...

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.