是否可以在函数中使用函数?
这样的事情:
Public Class Form1
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
Sub anim() Handles form2.Shown
Me.Refresh()
Do Until Me.Location.X = 350
form2.Location = New Point(Me.Location.X + 1, 250)
' System.Threading.Thread.Sleep(0.5)
Loop
form2.close()
End Sub
End Sub
End Class
答案 0 :(得分:3)
VB.NET中不可能有完全成熟的嵌套函数定义。该语言支持多行lambda表达式,看起来很像嵌套函数:
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
Dim anim =
Sub()
Me.Refresh()
...
End Sub
End Sub
但是有一些值得注意的差异:
Handles
条款。Implements
或Overrides
。Sub
定义。anim
实际上是委托而非功能。答案 1 :(得分:1)