注册 登录
编程论坛 VB.NET论坛

请教各位高手,vb.net(vs2010)窗体卸载和加载如何实现?谢谢。

HVB6 发布于 2017-06-28 21:27, 4596 次点击
以下是主窗体(Form1(命令按钮所在的窗体))的代码:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call my_ok()
    End Sub
End Class
以下是模块的代码:
Module Module1
    Public Sub my_ok()
        Dim s As String = "正在查找数据,请稍|等………"
        Dim frm1 As New Form1
        frm1.Show()
        frm1.Refresh()
        frm1.Close()
        frm1.Hide()
        frm1.Close()
        Dim frm2 As New Form2
        frm2.Show()
        frm2.Refresh()
        frm2.Label1.Text = s ‘第二个窗体有文本框,用于显示字符串(起到进度条的作用)
    End Sub
End Module
这些代码是希望主窗体关闭第二个窗体显示,但主窗体不关闭第二个窗体可以显示。
如何修改它们,实现希望的要求?谢谢。
网上说:主窗体只能隐藏不能关闭。
但这些代码主窗体并不隐藏。
4 回复
#2
xyxcc1772017-07-18 18:44
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim s As String = "正在查找数据,请稍|等………"
          Me.Hide()
         Dim frm2 As New Form2
        frm2.Show()
        frm2.Refresh()
        frm2.Label1.Text = s ‘第二个窗体有文本框,用于显示字符串(起到进度条的作用)
    End Sub
End Class
#3
FOXCONN20152017-07-23 14:17
meiyou yongguo
#4
qingcong332017-07-28 14:10
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm1 As New Form1
        Call my_ok()
        Me.Hide()
    End Sub

    Public Sub my_ok()
        Dim s As String = "正在查找数据,请稍等………"
        Dim frm2 As New Form2
        frm2.Show()
        frm2.Activate()
        frm2.Label1.Text = s
    End Sub
End Class
#5
怪叔叔2017-08-08 09:40
Public Class Form1
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         Call my_ok()
     End Sub
 End Class
以下是模块的代码:
Module Module1
     Public Sub my_ok()
         Dim s As String = "正在查找数据,请稍|等………"
         Form1.Hide()
         Form2.Show()
         Form2.Label1.Text = s ‘第二个窗体有文本框,用于显示字符串(起到进度条的作用)
    End Sub
 End Module
   Private Sub Form2_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
      Form.Show
   End Sub
既然已经写在了Form1按钮的点击事件中了,证明此时form1已经Show成功,直接隐藏Form1,
当Form2关闭后,主画面Form1就可以显示了。
1