获取最后打开的表单

Get the last open form

我想知道最后打开的表单名称和最后打开的表单名称..

我的代码关闭所有

  For Each Form In My.Application.OpenForms
        Form.Close()
    Next

form before the last and the last

表单按打开顺序添加到 OpenForms 集合中

这意味着您可以使用一些 LINQ 来创建获取最后 2 个的快捷方式:

Dim forms = My.Application.OpenForms.Reverse().Take(2).ToArray()

现在最后一个表格在 forms(0) 之前最后一个表格在 forms(1)