1

I searche the internet but could not find a solution to my problem: I am passing a set of parameters to a Sub where some of them are optional, i.e. I am leaving the position blank. In order to make the code readable and to know later on what I have left out I would like to state a comment there. I just could not find out any means on how to do that.

Here is an example:

MyBase.New( _
    pLfAIDLief, _
    pLfABezeichnung, _
    pLfAEkNtto, _
    pLfAMngEinhID, _
    pBestellEinheit, _
    , _                         ' PackEinheit
    pBarcode, _
    , _
    pLfAAvailable _
    )

The parameter PackEinheit is optional and is left blank but later on I would like to know that there was this particular parameter left out. The sytax I used creates an error, no matter whether i place the comment left or right of the line continuation underscore.

Any ideas?

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
pb_SKAT
  • 163
  • 2
  • 14

1 Answers1

2

You would have to upgrade to VS2015, where comments in multi-line statements are now allowed (see about three-quarters of the way down the page).

The auto-indenter doesn't like this specific case, but if you want this you might have to live with it:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Foo(
        , 'bar <- this line auto-indents to the left but it compiles
        "hello" 'baz
        )
End Sub


Public Sub Foo(Optional bar As String = "", Optional baz As String = "")
    'stub method
End Sub

Side Note: The line continuation character _ is not needed in most circumstances since VS2010 and this is one of those circumstances

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • Cheers Matt, I forgotten to mention that I am still on VS2013. So I will have to live with this I suppose... – pb_SKAT Aug 10 '15 at 11:32
  • 1
    If you fall into the criteria of "individual developers, open source projects, academic research, training, education and small professional teams" then Visual Studio 2015 Community is free of charge – Matt Wilko Aug 10 '15 at 12:15
  • Thanks again, Matt. Indeed I am very individual, i.e. not employed and working alone on projects. How do I qualify for VS2015 Community (that is what I have in 2013)? I was thinking of vs2015 because my customer purchased a new laptop and there he got a free upgrade from Windows 8.1 to 10, so in general vs2015 is most probably "closer" to 10. – pb_SKAT Aug 11 '15 at 11:41
  • If you qualify - you can just download it: https://go.microsoft.com/fwlink/?LinkId=532606&clcid=0x409 – Matt Wilko Aug 11 '15 at 12:14
  • Thank you Matt. I have downloaded the community.exe and now I am collecting the courage to install it, i.e. to change the tool in the middle of a project. I will read more about the differences between 2013 and 2015 and then make my mind up whether I take the risk or not. Thank you anyway. – pb_SKAT Aug 12 '15 at 15:52