I have problems with this Code:
Public Sub SetPropertyValue(ByVal strPropertyPath As String, ByVal obj
As Object, ByVal Value As Object)
.....
Dim t_PropertyInfos() As System.Reflection.PropertyInfo =
(t_obj.GetType).GetProperties
For ii = 0 To t_PropertyInfos.Length - 1
If t_PropertyInfos(ii).Name = t_strProperty Then
t_PropertyInfos(ii).SetValue(t_obj, Value, Nothing)
End If
Next
I get the following error message:
An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: Zieltyp kann nicht zu primitiven Typ erweitert
werden.
"t_PropertyInfos(ii)" required a Double und the "Value" is a String,
for example "10".
I can get the Type of my Property with:
Dim t_type As Type = t_PropertyInfos(ii).PropertyType
But how can i convert my Value in this type?
I tryed:
Value = CType(Value, t_type)
and alsoe
Value = DirectCast(Value, t_type)
There are both a Syntax Error:
"Type 't_type' is not defined.
Is there any method to convert a variable to a dynamicl type? 4 2830
Dim MyDouble As Double = Double.Parse(MyString);
<a.*******@gmx.ch> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com... I have problems with this Code:
Public Sub SetPropertyValue(ByVal strPropertyPath As String, ByVal obj As Object, ByVal Value As Object) .... Dim t_PropertyInfos() As System.Reflection.PropertyInfo = (t_obj.GetType).GetProperties For ii = 0 To t_PropertyInfos.Length - 1 If t_PropertyInfos(ii).Name = t_strProperty Then t_PropertyInfos(ii).SetValue(t_obj, Value, Nothing) End If Next
I get the following error message: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Zieltyp kann nicht zu primitiven Typ erweitert werden.
"t_PropertyInfos(ii)" required a Double und the "Value" is a String, for example "10".
I can get the Type of my Property with: Dim t_type As Type = t_PropertyInfos(ii).PropertyType
But how can i convert my Value in this type?
I tryed: Value = CType(Value, t_type) and alsoe Value = DirectCast(Value, t_type)
There are both a Syntax Error: "Type 't_type' is not defined.
Is there any method to convert a variable to a dynamicl type?
I'm not sure, but have you tried the following?
CType(Value, t_obj.GetType)
or maybe
CType(Value, GetType(t_obj))
Hope this helps,
Joris
"a.*******@gmx.ch" wrote: I have problems with this Code:
Public Sub SetPropertyValue(ByVal strPropertyPath As String, ByVal obj As Object, ByVal Value As Object) ..... Dim t_PropertyInfos() As System.Reflection.PropertyInfo = (t_obj.GetType).GetProperties For ii = 0 To t_PropertyInfos.Length - 1 If t_PropertyInfos(ii).Name = t_strProperty Then t_PropertyInfos(ii).SetValue(t_obj, Value, Nothing) End If Next
I get the following error message: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Zieltyp kann nicht zu primitiven Typ erweitert werden.
"t_PropertyInfos(ii)" required a Double und the "Value" is a String, for example "10".
I can get the Type of my Property with: Dim t_type As Type = t_PropertyInfos(ii).PropertyType
But how can i convert my Value in this type?
I tryed: Value = CType(Value, t_type) and alsoe Value = DirectCast(Value, t_type)
There are both a Syntax Error: "Type 't_type' is not defined.
Is there any method to convert a variable to a dynamicl type?
This would be go when "t_PropertyInfos(ii)" required allways a Double,
but in the "t_PropertyInfos(ii+1) requires perhaps a Int. So I don't
know at Design-Time which type my property need.
Stuart Irving schrieb: Dim MyDouble As Double = Double.Parse(MyString);
There are also both a Syntax Error
Joris Zwaenepoel schrieb: I'm not sure, but have you tried the following?
CType(Value, t_obj.GetType) or maybe CType(Value, GetType(t_obj))
Hope this helps,
Joris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James A. Donald |
last post by:
I am contemplating getting into Python, which is used by engineers I
admire - google and Bram Cohen, but was horrified to read
"no variable or argument declarations are necessary."
Surely that...
|
by: Jim Bancroft |
last post by:
Hi everyone,
A basic one here, I think. I haven't found the pattern yet, but
sometimes when I cast a variable to another type using the "C" style cast
operator the compiler refuses to play...
|
by: Martin |
last post by:
I would like to convert this code to VB.NET. Can someone help.
Thanks.
Dim X()
Dim i As Long
Dim objShell, objFolder, objFolderItem
Dim FSO, oFolder, Fil
Sub MainExtractData()
|
by: Allerdyce.John |
last post by:
Do I need to convert string to integer in python? or it will do it for
me (since dynamic type)?
In my python script, I have this line:
x /= 10;
when i run it, I get this error:
TypeError:...
|
by: Polaris431 |
last post by:
I have a buffer that holds characters. Four characters in a row
represent an unsigned 32 bit value. I want to convert these characters
to a 32 bit value. For example:
char buffer;
buffer =...
|
by: Saber |
last post by:
In an ASP.Net Website I've a string and want to convert that to Type.
Let's consider the string "Class1"
I tried: Type t = Type.GetType("Class1");
but it returns null.
|
by: yinglcs |
last post by:
Can you please tell me why the following code does not work in python?
My guess is I need to convert 'count' from a string to an integer. How
can I do that?
And my understanding is python is a...
|
by: mrajanikrishna |
last post by:
Hi Friends,
I am accepting a number from the user entered in a textbox.
I want to assign to a variable in my code and assignt this to that
variable.
double num1 = (double)txtNum1.text;
...
|
by: tickle |
last post by:
Need to convert this PL/SQL script to Dynamic SQL Method 2
* copybook - celg02u3.sql SIR 24265 *
* updates dt_deny for all rows in *
* ...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |