You could record it as (note the default values for the optional
parameters):
Public Function Method1(Byval ar as object, Optional ByVal strWHFrom As
String = String.Empty, Optional ByVal strWHTo As String = String.Empty) As
String
....
If strWHFrom Is String.Empty AndAlso strWHTo Is String.Empty Then
strSql = "............"
ElseIf strWHFrom Is String.Empty Then
strSql = "............"
ElseIf strWHTo Is String.Empty Then
strSql = "............."
Else
If strWHFrom.Trim = strWHTo.Trim Then
strSql = "............."
Else
strSql = "............."
End If
End Function
or you could create overloaded methods instead:
Public Function Method1(Byval ar as object) As String
Return Method1(ar, String.Empty, String.Empty)
End Function
Public Function Method1(Byval ar as object, ByVal strWHFrom As String) As
String
Return Method1(ar, strWHFrom, String.Empty)
End Function
Public Function Method1(Byval ar as object, ByVal strWHFrom As String,
ByVal strWHTo As String) As String
....
If strWHFrom Is String.Empty AndAlso strWHTo Is String.Empty Then
strSql = "............"
ElseIf strWHFrom Is String.Empty Then
strSql = "............"
ElseIf strWHTo Is String.Empty Then
strSql = "............."
Else
If strWHFrom.Trim = strWHTo.Trim Then
strSql = "............."
Else
strSql = "............."
End If
End Function
<br******@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I now converting vb6 code to vb.net code
Let me descrip my problem first
i got a Function e.g.
Public Function Method1(Byval ar as object, Optional ByVal strWHFrom As
String, Optional ByVal strWHTo As String) as string
.......
If IsMissing(strWHFrom) And IsMissing(strWHTo) Then
strSql = "............"
ElseIf IsMissing(strWHFrom) And Not IsMissing(strWHTo) Then
strSql = "............"
ElseIf Not IsMissing(strWHFrom ) And IsMissing(strWHTo) Then
strSql = "............."
Else
If IsNull(strWHFrom ) And IsNull(strWHTo) Then
strSql = "................"
ElseIf Len(strWHFrom )=0 And len(strWHTo)=0 Then
strSql = "..............."
Else
If Trim$(strWHFrom ) = Trim$(strWHTo) Then
strSql = "............."
Else
strSql = "............."
End If
End If
End If
End Funciton
This function work well in vb6
But How I going to code this with vb.net, vb.net seem like cant
differentciate the parameter got pass in or not. and also how to
convert the IsNull
Is it mean that I must put some SPEACIAL default value to the Optional
Parameter to detect that particular parameter got pass in or not?
Thank you