Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2004, 01:12 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default Problem with Reflection.FieldInfo.SetValue method

I'm trying to set the value of a property using the Reflection.FieldInfo.SetValue method.

I need to perform a cast on the basis of the field I'm passing the object in to - for example, the JobNumber field requires a string value, so we have to cast the object variable to a string.

This differs with every property we set; therefore if we're setting DeliveryQuantity we'll want to cast to Integer, if we're setting JobNumber we'll want to cast to String, if we're setting DeliveryDate we'll want to cast to Date, etc.

I don't want to have a massive 'Select Case' statement where we work out what property we're setting then do the CType(x,y); at least, not unless there is no other way round at all.

The SetValue(Object,Object,BindingFlags,Binder,Culture Info) method looks like it might do what I need, but the .Net documentation might as well be greek for all the sense I can make of it. Is there anyone who does understand this method, and can explain it to me?

Thanks very much







Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Error when updating data (setvalue) darrenb Access VBA 3 May 3rd, 2007 09:14 PM
SetValue doesn't work with DateTimePicker Infinity VB Components 0 January 4th, 2007 03:05 AM
Problem in Code about "SetValue" arctica82 Pro VB.NET 2002/2003 2 April 15th, 2005 03:39 PM
Problem with a method? savoym C# 1 January 6th, 2005 09:34 AM
FindControl Method problem jbenson001 ASP.NET 1.x and 2.0 Application Design 3 March 8th, 2004 10:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.