是否可以在sub中有一个sub?
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 :(得分:1)
你可以这样做:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim form2 As New Form2()
Dim anim = Sub()
form2.Refresh()
Do Until form2.Location.X = 350
form2.Location = New Point(form2.Location.X + 1, 250)
' System.Threading.Thread.Sleep(0.5)
Loop
End Sub
AddHandler form2.Shown, anim
form2.Show()
End Sub