G
Guest
In the example below, the indicated line yields a syntax error. If the
phrase 'New Test1' appears where an expression is expected, it seems to work
ok. But if it appears where a statement is expected, it does not work. Why
does vb syntax have this peculiar asymmetry? Please no comments about the
foolishness of the code, it just minimally illustrates my question. Also,
the issue poses no inconvenience - I am just curious.
Public Class test1
Public Sub sub1(ByVal i As Integer)
End Sub
Public Function func1(ByVal i As Integer) As Integer
End Function
Public Shared Sub driver()
Dim t As New test1
Dim i As Integer
i = t.func1(i)
i = (New test1).func1(i) ' this compiles ok
t.sub1(i)
(New test1).sub1(i) ' syntax error on this line
End Sub
End Class
phrase 'New Test1' appears where an expression is expected, it seems to work
ok. But if it appears where a statement is expected, it does not work. Why
does vb syntax have this peculiar asymmetry? Please no comments about the
foolishness of the code, it just minimally illustrates my question. Also,
the issue poses no inconvenience - I am just curious.
Public Class test1
Public Sub sub1(ByVal i As Integer)
End Sub
Public Function func1(ByVal i As Integer) As Integer
End Function
Public Shared Sub driver()
Dim t As New test1
Dim i As Integer
i = t.func1(i)
i = (New test1).func1(i) ' this compiles ok
t.sub1(i)
(New test1).sub1(i) ' syntax error on this line
End Sub
End Class