Click here to Skip to main content
15,914,225 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Need help with Image Pin
Luc Pattyn20-Jun-10 18:06
sitebuilderLuc Pattyn20-Jun-10 18:06 
GeneralRe: Need help with Image Pin
jaygalway211620-Jun-10 18:44
jaygalway211620-Jun-10 18:44 
GeneralRe: Need help with Image Pin
Luc Pattyn20-Jun-10 19:04
sitebuilderLuc Pattyn20-Jun-10 19:04 
QuestionVisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
QuickBooksDev19-Jun-10 1:19
QuickBooksDev19-Jun-10 1:19 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
AnnieMacD19-Jun-10 1:26
AnnieMacD19-Jun-10 1:26 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
Luc Pattyn19-Jun-10 1:58
sitebuilderLuc Pattyn19-Jun-10 1:58 
AnswerRe: VisStudio (VB.Net) 2005 to 2008/2010 - Errors just returning from functions Pin
DaveAuld19-Jun-10 4:38
professionalDaveAuld19-Jun-10 4:38 
QuestionCoalesce -- Any suggestions on how to improve this? Pin
Gregory Gadow18-Jun-10 8:08
Gregory Gadow18-Jun-10 8:08 
In rewriting a website, I have found it useful to be able to select the first non-empty value from a list, where "empty" is defined as Nothing, DBNull.Value and String.Empty. The code I wrote looks like this:
VB
Public Shared Function Coalesce(ByVal ParamArray Items() As Object) As Object
    Dim Result As Object = Nothing

    For Each Obj As Object In Items
        If Obj IsNot Nothing AndAlso Obj IsNot DBNull.Value Then
            If Not String.IsNullOrEmpty(Obj.ToString) Then
                Result = Obj
                Exit For
            End If
        End If
    Next

    Return Result
End Function

This way, I could write something like this:
VB
Response.Write(Toolbox.Coalesce(DR("TerminatedDate"), "%nbsp;").ToString)

(Yeah, the nbsp is wrong; I couldn't get it to show up otherwise.) The inputs might be various types -- database fields, date variables, strings, etc. The output will almost always be converted into a String, but not necessarily.

This looks like it should do what I want, but I'm not fully convinced. Any suggestions on how to improve this?
AnswerRe: Coalesce -- Any suggestions on how to improve this? Pin
rhuiden18-Jun-10 10:26
rhuiden18-Jun-10 10:26 
QuestionSingle Sign on Pin
berba18-Jun-10 2:59
berba18-Jun-10 2:59 
AnswerRe: Single Sign on Pin
Dave Kreskowiak18-Jun-10 8:06
mveDave Kreskowiak18-Jun-10 8:06 
GeneralRe: Single Sign on Pin
berba22-Jun-10 23:15
berba22-Jun-10 23:15 
GeneralRe: Single Sign on Pin
Dave Kreskowiak23-Jun-10 1:33
mveDave Kreskowiak23-Jun-10 1:33 
QuestionPowerPoint Application Pin
rdop18-Jun-10 1:13
rdop18-Jun-10 1:13 
AnswerRe: PowerPoint Application Pin
ddecoy18-Jun-10 1:16
ddecoy18-Jun-10 1:16 
GeneralRe: PowerPoint Application Pin
rdop18-Jun-10 1:36
rdop18-Jun-10 1:36 
GeneralRe: PowerPoint Application Pin
JR21218-Jun-10 2:13
JR21218-Jun-10 2:13 
GeneralRe: PowerPoint Application Pin
EliottA18-Jun-10 2:27
EliottA18-Jun-10 2:27 
GeneralRe: PowerPoint Application Pin
JR21218-Jun-10 20:38
JR21218-Jun-10 20:38 
GeneralRe: PowerPoint Application [modified] Pin
MsmVc18-Jun-10 2:31
MsmVc18-Jun-10 2:31 
GeneralRe: PowerPoint Application Pin
EliottA18-Jun-10 2:33
EliottA18-Jun-10 2:33 
GeneralRe: PowerPoint Application [modified] Pin
MsmVc18-Jun-10 2:42
MsmVc18-Jun-10 2:42 
GeneralRe: PowerPoint Application Pin
JR21221-Jun-10 3:36
JR21221-Jun-10 3:36 
Questionnewbie question on updating Access mdb tables Pin
john12617-Jun-10 5:46
john12617-Jun-10 5:46 
QuestionRe: newbie question on updating Access mdb tables Pin
DaveAuld17-Jun-10 6:26
professionalDaveAuld17-Jun-10 6:26 

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.