如何在以下功能中显示用户的多个选定值?

时间:2012-09-04 13:35:11

标签: vb.net

Public Function StartTableCell( _
  Optional ByVal align As String = "", _
  Optional ByVal valign As String = "", _
  Optional ByVal colspan As String = "", _
  Optional ByVal rowspan As String = "", _
  Optional ByVal width As String = "", _
  Optional ByVal height As String = "") As String

    Dim _StrBuil As New StringBuilder()

End Function

如何显示调用者传入值的参数中的值?例如,如果align""则不应显示。

1 个答案:

答案 0 :(得分:0)

最简单的方法是检查每个参数并逐个构建StringBuilder

例如:

Dim _StrBuil As New StringBuilder()
If Not String.IsNullOrEmpty(align)
    _StrBuil.Append(("align: """ + align + """")
End If
If Not String.IsNullOrEmpty(valign)
    _StrBuil.Append(("valign: """ + valign + """")
End If 
'etc.  
Return "<td " + _StrBuil.ToString + ">"