Click here to Skip to main content
16,004,977 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Stored Procs Pin
Pete Newman25-Oct-06 22:07
Pete Newman25-Oct-06 22:07 
GeneralRe: Stored Procs Pin
Pete Newman26-Oct-06 4:13
Pete Newman26-Oct-06 4:13 
GeneralRe: Stored Procs Pin
Are Jay27-Oct-06 3:48
Are Jay27-Oct-06 3:48 
GeneralRe: Stored Procs Pin
Pete Newman27-Oct-06 3:51
Pete Newman27-Oct-06 3:51 
Question"Is Nothing" not running Pin
amapumu24-Oct-06 22:25
amapumu24-Oct-06 22:25 
AnswerRe: "Is Nothing" not running Pin
Dave Kreskowiak25-Oct-06 5:16
mveDave Kreskowiak25-Oct-06 5:16 
GeneralRe: "Is Nothing" not running Pin
amapumu26-Oct-06 3:05
amapumu26-Oct-06 3:05 
GeneralRe: "Is Nothing" not running Pin
Dave Kreskowiak26-Oct-06 5:43
mveDave Kreskowiak26-Oct-06 5:43 
Connected will return True or False, never Nothing. "Nothing" is not a value. It's a reference, or the lack of a reference to an object. Nothing means "this variable doesn't point to an instance of anything". So,
When the propety "connected" (Boolean type) is nothing...

will NEVER happen. Value types, like Integers and Booleans, will ALWAYS return a value, not a reference.

This is something I whipped up real quick. It's got some serious limitations and drawbacks, but it should give you the idea:
Private Function IsNull(ByRef obj As Object, ByVal prop As String) As Boolean
    Dim memberInfos() As MemberInfo = obj.GetType().GetMember(prop, BindingFlags.Instance Or BindingFlags.Public)
    If memberInfos.Length > 0 Then
        For Each mi As MemberInfo In memberInfos
            Debug.WriteLine(String.Format("Object Declaring Type: {0}", mi.DeclaringType.ToString()))
            Debug.WriteLine(String.Format("Object Reflected Type: {0}", mi.ReflectedType.ToString()))
            Debug.WriteLine(String.Format("    {0} is a {1}", mi.Name, mi.MemberType.ToString()))
            Select Case mi.MemberType
                Case MemberTypes.Property
                    Dim pi As PropertyInfo = obj.GetType().GetProperty(prop)
                    Dim v As Object = Nothing
                    v = pi.GetValue(obj, Nothing)
                    Debug.WriteLine(String.Format("    Value: {0} ({1})", v, pi.PropertyType().ToString()))
                    If v Is Nothing Then
                        Return True
                    Else
                        Return False
                    End If
            End Select
        Next
    Else
        Throw New InvalidArgumentException("Property name not found!")
    End If
End Function



Dave Kreskowiak
Microsoft MVP - Visual Basic


QuestionSaving an Image in VB.NET Pin
Zaegra24-Oct-06 21:09
Zaegra24-Oct-06 21:09 
AnswerRe: Saving an Image in VB.NET Pin
Dave Kreskowiak25-Oct-06 5:12
mveDave Kreskowiak25-Oct-06 5:12 
GeneralRe: Saving an Image in VB.NET Pin
Zaegra27-Oct-06 1:19
Zaegra27-Oct-06 1:19 
QuestionHow to insert records from DataGridView to SQL Server database Pin
VS200524-Oct-06 20:59
VS200524-Oct-06 20:59 
AnswerRe: How to insert records from DataGridView to SQL Server database Pin
Dave Kreskowiak25-Oct-06 4:48
mveDave Kreskowiak25-Oct-06 4:48 
QuestionRe: How to insert records from DataGridView Of Visual Studio 2005 to SQL Server database Pin
VS200525-Oct-06 15:59
VS200525-Oct-06 15:59 
QuestionBest book for 'Working with graphics in VB.Net' or GDI+? Pin
BetimD24-Oct-06 20:44
BetimD24-Oct-06 20:44 
AnswerRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Sexton24-Oct-06 21:32
Dave Sexton24-Oct-06 21:32 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Zaegra24-Oct-06 23:55
Zaegra24-Oct-06 23:55 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Sexton25-Oct-06 2:36
Dave Sexton25-Oct-06 2:36 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Kreskowiak25-Oct-06 3:29
mveDave Kreskowiak25-Oct-06 3:29 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Sexton25-Oct-06 6:05
Dave Sexton25-Oct-06 6:05 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Kreskowiak25-Oct-06 6:53
mveDave Kreskowiak25-Oct-06 6:53 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Sexton25-Oct-06 20:13
Dave Sexton25-Oct-06 20:13 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
BetimD24-Oct-06 23:58
BetimD24-Oct-06 23:58 
GeneralRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Dave Sexton25-Oct-06 2:44
Dave Sexton25-Oct-06 2:44 
AnswerRe: Best book for 'Working with graphics in VB.Net' or GDI+? Pin
Zaegra25-Oct-06 0:00
Zaegra25-Oct-06 0:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.