This was asked yesterday and it works without "error" but it's not really doing what expected.
I need to append data to a variable IF and ONLY if that variable contains data. If the testing variable is empty, it should move on to the next test.
The following adds lines that test false (variables that contain nothing are still having their data concat. to the _results ).
Any idea how to clean this up?
I need to append data to a variable IF and ONLY if that variable contains data. If the testing variable is empty, it should move on to the next test.
The following adds lines that test false (variables that contain nothing are still having their data concat. to the _results ).
Any idea how to clean this up?
Code:
Dim _meta_start As String = "<meta name='"
Dim _meta_end As String = "'>"
' begin writing our results page
If (Not _author Is Nothing) Then
_results = _results & _meta_start & "results'" & " content='" & _author & _meta_end & vbCrLf
End If
If (Not _keywords Is Nothing) Then
_results = _results & _meta_start & "keywords'" & " content='" & _keywords & _meta_end & vbCrLf
End If
If (Not _description Is Nothing) Then
_results = _results & _meta_start & "description'" & " content='" & _description & _meta_end & vbCrLf
End If
If (Not _copyright Is Nothing) Then
_results = _results & _meta_start & "copyright'" & " content='" & _copyright & _meta_end & vbCrLf
End If
If (Not _abstract Is Nothing) Then
_results = _results & _meta_start & "abstract" & " content='" & _abstract & _meta_end & vbCrLf
End If
If (Not _distributor Is Nothing) Then
_results = _results & _meta_start & "distributor'" & " content='" & _distributor & _meta_end & vbCrLf
End If
If (Not _robots Is Nothing) Then
_results = _results & _meta_start & "robots'" & " content='" & _robots & _meta_end & vbCrLf
End If
If (Not _rating Is Nothing) Then
_results = _results & _meta_start & "rating'" & " content='" & _rating & _meta_end & vbCrLf
End If
If (Not _distribution Is Nothing) Then
_results = _results & _meta_start & "distribution'" & " content='" & _distribution & _meta_end & vbCrLf
End If
If (Not _language Is Nothing) Then
_results = _results & _meta_start & "language'" & " content='" & _language & _meta_end & vbCrLf
End If
Results.Text = _results