Advertisement

06.17.2008 at 08:03AM PDT, ID: 23491793
[x]
Attachment Details

changing IIF syntex - beginner /am i coding this correctly?

Asked by Tania_Farmer in Microsoft Visual Basic.Net, Programming for ASP.NET

Tags: vb asp.net

Hi,
I have this in my articles.ascx.vb  - calling from xml file.

Partial Class articleDefault
    Inherits System.Web.UI.UserControl

    Public Function getArticleAuthor() As String
        Return IIf(XPath("article/author") = "", "", "By  " & XPath("article/author") & "    " & XPath("summary") & ":: Published:  "& XPath("article/pubDate") & ".  ")
    End Function
   
   Public Function getPubDate() As String
        Return IIf(XPath("pubDate") = "", "<dd>&nbsp;", "<dd class=""smaller"">  " & XPath("pubDate") & "&nbsp; ")
    End Function

    Public Function getSummary() As String
        Return IIf(XPath("summary") = "", "", "<dd>  " & XPath("summary") & " <br class=""clearfloat"" /></dd>")
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
End Class

I read that using IIF in VB is quirky and very slow.  So I am trying to switch to this:

Partial Class articleDefault
    Inherits System.Web.UI.UserControl

    Public Function getArticleAuthor() As String
      Dim value As String = XPath("article/author")
             If value is Nothing Then
                   Return "empty"
            Else
                  Return "By  " & XPath("article/author") & "    " & XPath("summary") & ":: Published:&nbsp; "& XPath("article/pubDate") & ".&nbsp; "
               End If
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
End Class

 It is working but I just wanted my code checked - I am very new to this.  Is there a better /more efficient way to do this?  IF so advise is greatly appreciated.

I was going to do the change to each public function.

Cheers
TaniaStart Free Trial
[+][-]06.17.2008 at 08:16AM PDT, ID: 21803959

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Programming for ASP.NET
Tags: vb asp.net
Sign Up Now!
Solution Provided By: VBRocks
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.17.2008 at 09:25AM PDT, ID: 21804774

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 10:15AM PDT, ID: 21805294

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628