A
a.frank81
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?
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?