F
FB's .NET Dev PC
I'm trying to create a general-purpose routine to update a value in a data
location on a remote server. The client-server protocol is OPC, but that
isn't immediately important to my question. The part that is important is
that the value passed to the server has to be the correct data type. I am
trying to convert the input (as an object) to the correct data type, said
type being read from the server immediately prior to update.
The MSDN description states "Expression as object, type as object", so I
tried this:
Sub OPCWrite(ByVal Tag As IDN.IO.IOTag, ByVal Value As Object)
Dim LocVal As Object = Tag.Value
Dim ValType As Object = Tag.DataType
LocVal = CType(Value, ValType)
Tag.Write(LocVal)
End Sub
That yielded a "ValType is not defined", so I tried this:
Sub OPCWrite(ByVal Tag As IDN.IO.IOTag, ByVal Value As Object)
Dim LocVal As Object = Tag.Value
Dim ValType As String = Tag.DataType.ToString
LocVal = CType(Value, ValType)
Tag.Write(LocVal)
End Sub
which yielded the same error. Is there a way to accomplish a generic
type-switch in VB .NET 2003?
Thanks
Fred Bourdelier
Database Admin
Tucson AZ
location on a remote server. The client-server protocol is OPC, but that
isn't immediately important to my question. The part that is important is
that the value passed to the server has to be the correct data type. I am
trying to convert the input (as an object) to the correct data type, said
type being read from the server immediately prior to update.
The MSDN description states "Expression as object, type as object", so I
tried this:
Sub OPCWrite(ByVal Tag As IDN.IO.IOTag, ByVal Value As Object)
Dim LocVal As Object = Tag.Value
Dim ValType As Object = Tag.DataType
LocVal = CType(Value, ValType)
Tag.Write(LocVal)
End Sub
That yielded a "ValType is not defined", so I tried this:
Sub OPCWrite(ByVal Tag As IDN.IO.IOTag, ByVal Value As Object)
Dim LocVal As Object = Tag.Value
Dim ValType As String = Tag.DataType.ToString
LocVal = CType(Value, ValType)
Tag.Write(LocVal)
End Sub
which yielded the same error. Is there a way to accomplish a generic
type-switch in VB .NET 2003?
Thanks
Fred Bourdelier
Database Admin
Tucson AZ