MsgBox问题 [英] MsgBox problem

查看:102
本文介绍了MsgBox问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我为什么下面的代码无法通过(Me.Close())读取.提前谢谢.

Hi, can anyone please tell me why the code below does not read pass the (Me.Close()). Thanks in advance.

Private Sub btnALogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnALogIn.Click
        If txtAUserName.Text = "" Then
            MsgBox("Please Enter An Administrator Username")
            txtAUserName.Focus()
        Else
            If txtAPassword.Text = "" Then
                MsgBox("Please Enter An Administrator Password")
                txtAPassword.Focus()
            Else
                If txtAUserName.Text = "me555" Then
                    If txtAPassword.Text = "9000" Then
                        SalesMainForm.Enabled = True
                        Me.Close()
                    Else
                        MsgBox("Access Denied. Please Check Your Administrator Username And/Or Password", MsgBoxStyle.Information)
                        txtAUserName.Text = ""
                        txtAPassword.Text = ""
                    End If
                End If
            End If
        End If
    End Sub

推荐答案

我认为您使用的方法非常糟糕.
要到达那里,您需要同时具有真实性
In my opinion, you use a really bad approach.
To get there you need SIMULTANEOUSLY to have true
txtAUserName.Text = ""
      txtAUserName.Text = "me555"
      txtAPassword.Text = "" 
      txtAPassword.Text = "9000"



每次使用txtXXX.Focus()程序执行时,由于它遇到"Else",因此请退出方法.

我认为您应该使用嵌入式Validation事件.例如,在此处.



Every time you use txtXXX.Focus() program execution go out of your method since it meets "Else".

I think you should use embedded Validation events. Look here for example.


这篇关于MsgBox问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆