Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB.NET:多个表单的问题_Vb.net_Forms - Fatal编程技术网

VB.NET:多个表单的问题

VB.NET:多个表单的问题,vb.net,forms,Vb.net,Forms,大家好!我在VB.NET中有一个问题。在创建和测试我的GUI以显示工资系统主页的登录屏幕时,出现了这个问题 启动屏幕正常加载,并显示登录表单。我输入用户名和密码(例如用户名:Admin,密码:12345),登录成功。问题是:当主菜单出现时,登录屏幕再次出现,此时,该屏幕应该已经关闭。我在使用Show、Hide和Close时有什么问题吗 这是我三张表格的代码 A.启动屏幕 Public Class frmSplashScreen Private Sub tmrSplashScreen_Tick(

大家好!我在VB.NET中有一个问题。在创建和测试我的GUI以显示工资系统主页的登录屏幕时,出现了这个问题

启动屏幕正常加载,并显示登录表单。我输入用户名和密码(例如用户名:Admin,密码:12345),登录成功。问题是:当主菜单出现时,登录屏幕再次出现,此时,该屏幕应该已经关闭。我在使用Show、Hide和Close时有什么问题吗

这是我三张表格的代码

A.启动屏幕

Public Class frmSplashScreen

Private Sub tmrSplashScreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplashScreen.Tick
    Me.Hide()
    frmLogin.Focus()
    frmLogin.Show()
End Sub

End Class
B.登录表(用于系统访问)

末级

最后:

C.主菜单

Public Class frmMainMenu

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

    End

End Sub

Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Me.WindowState = FormWindowState.Maximized

End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click

    MsgBox("Byte" & vbCrLf & "By: JU-CHAN", vbInformation, "Byte Payroll System")

End Sub
末级


非常感谢您的帮助。谢谢!:)

我敢打赌你的问题是,你启动屏幕中的计时器仍在触发滴答事件,并再次打开登录页面

在隐藏启动屏幕之前,可以添加
tmrSplashScreen.Stop()


或者更好。完全摆脱闪屏,它们是邪恶的

我敢打赌你的问题是,你启动屏幕中的计时器仍在触发滴答事件,并再次打开登录页面

在隐藏启动屏幕之前,可以添加
tmrSplashScreen.Stop()


或者更好。完全摆脱闪屏,它们是邪恶的

您的启动屏幕不应控制登录表单的显示时间。只有在程序启动期间,当程序在后台执行大量处理时,才应在程序实际启动之前使用启动屏幕。仅仅为了做而显示一个启动屏幕会惹恼最终用户

由于上面的基本登录屏幕看起来不会占用大量资源,因此更好的选择是使用以下流程:

显示登录屏幕
如果密码成功,则
-显示启动屏幕
-在后台加载应用程序
-加载应用程序后,显示主窗口并隐藏飞溅屏幕

这方面的一些示例代码如下:

Module modMain
    'In a module 
    Public frmSpl As frmSplash
    Public frmMain As frmMainMenu

    Public Sub Main(ByVal args() as String)
        dim frmLogin as New frmLogin

        'Assume frmLogin is a modal form
        frmLogin.Show

        'A public property set on the Login form
        If frmLogin.Passed = True Then Do
            'Load and display the splash screen
            frmSpl = New frmSplash
            frmSpl.Cursor = Cursors.WaitCursor
            frmSpl.Show()
            Application.DoEvents()

            'If there is any code needed to run before displaying the Main Form
            'do it here 

            frmMain = New frmMainMenu

            'Begin running standard application loop for frmMainMenu
            Application.Run(frmMain)
        End If
    End Sub
End Module
然后,在frmMainMenu中,您的代码类似于:

Public Class frmMainMenu

    Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            Me.Cursor = Cursors.WaitCursor
            Me.SuspendLayout

            Me.WindowState = FormWindowState.Maximized

            'Put any other loading code needed for this form here
        Catch (ex as Exception)
            'Handle exceptions here
        Finally
            'Hide the splash screen
            frmSpl.Hide()
            frmSpl.Dispose()

            'Display the form
            Me.ResumeLayout
            Me.Cursor = Cursors.Default
            Me.Show
        End Try

    End Sub

您的启动屏幕不应控制登录窗体的显示时间。只有在程序启动期间,当程序在后台执行大量处理时,才应在程序实际启动之前使用启动屏幕。仅仅为了做而显示一个启动屏幕会惹恼最终用户

由于上面的基本登录屏幕看起来不会占用大量资源,因此更好的选择是使用以下流程:

显示登录屏幕
如果密码成功,则
-显示启动屏幕
-在后台加载应用程序
-加载应用程序后,显示主窗口并隐藏飞溅屏幕

这方面的一些示例代码如下:

Module modMain
    'In a module 
    Public frmSpl As frmSplash
    Public frmMain As frmMainMenu

    Public Sub Main(ByVal args() as String)
        dim frmLogin as New frmLogin

        'Assume frmLogin is a modal form
        frmLogin.Show

        'A public property set on the Login form
        If frmLogin.Passed = True Then Do
            'Load and display the splash screen
            frmSpl = New frmSplash
            frmSpl.Cursor = Cursors.WaitCursor
            frmSpl.Show()
            Application.DoEvents()

            'If there is any code needed to run before displaying the Main Form
            'do it here 

            frmMain = New frmMainMenu

            'Begin running standard application loop for frmMainMenu
            Application.Run(frmMain)
        End If
    End Sub
End Module
然后,在frmMainMenu中,您的代码类似于:

Public Class frmMainMenu

    Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            Me.Cursor = Cursors.WaitCursor
            Me.SuspendLayout

            Me.WindowState = FormWindowState.Maximized

            'Put any other loading code needed for this form here
        Catch (ex as Exception)
            'Handle exceptions here
        Finally
            'Hide the splash screen
            frmSpl.Hide()
            frmSpl.Dispose()

            'Display the form
            Me.ResumeLayout
            Me.Cursor = Cursors.Default
            Me.Show
        End Try

    End Sub

计时器一直滴答作响,导致启动屏幕重新加载,然后隐藏,再次显示登录屏幕

尝试将其放入tmrSplashScreen勾号处理程序:

tmrSplashScreen.Enabled = False

计时器一直滴答作响,导致启动屏幕重新加载,然后隐藏,再次显示登录屏幕

尝试将其放入tmrSplashScreen勾号处理程序:

tmrSplashScreen.Enabled = False

那个闪屏的目的是让人们无缘无故地等待,从而搞乱他们吗?另外,我假设这是伪造的代码,并且在生产系统中没有这样的硬编码密码。对吧?嗯。。。你可能是对的,但是登录屏幕的if-else只是为了让我的讲师检查我的整个系统进行评分。我完全了解登录屏幕在现实世界程序中的实际用途。但是,我会考虑你的帖子,你说飞溅屏幕是邪恶的。我同意这一点那个闪屏的目的是让人们无缘无故地等待,从而搞乱他们吗?另外,我假设这是伪造的代码,并且在生产系统中没有这样的硬编码密码。对吧?嗯。。。你可能是对的,但是登录屏幕的if-else只是为了让我的讲师检查我的整个系统进行评分。我完全了解登录屏幕在现实世界程序中的实际用途。但是,我会考虑你的帖子,你说飞溅屏幕是邪恶的。我同意这一点