I am trying to recreate the following C# code in VB6:
private void ChangeTab(string tabName, bool clearAll = true)
{
Yadyyada(tabName);
if (clearAll)
{
DoMoreStuff();
}
}
Here is what I have so far:
Private Sub ChangeTab(ByVal tabName As String, Optional ByVal clearAll As Boolean)
Yadyyada(tabName)
If clearAll = True Then
DoMoreStuff
End If
End Sub
So far so good apart from the default parameter. Can I assign clearAll a default value of true in the method signature in the same way I can in C# or do I just need to do this at the start of the method?
Thanks
Wow this takes me back.. can I ask why you’re converting backwards technology-wise?
Anyway, you can use the Optional keyword:
Your issue is using ByVal. From memory, everything in VB6 was ByVal unless explicitly stated.
EDIT: I’m wrong. Default was ByRef.. it’s been so long!