Home > Software engineering >  Beginner, if the problems in the else
Beginner, if the problems in the else

Time:10-01

The problem is the two sentences, can only run one, two error together, comments one,
User_Jurisdiction=objRs. Fields (" authority "). The Value
Sys_User_Name=objRs. Fields (" username "). The Value

The code is as follows:
Option Explicit
Public User_Jurisdiction As String
Public Sys_User_Name As String
Const MaxLogTimes As Integer=3 'definition allows the user to serious this login information most times
Private Sub cmdCancel_Click ()

Dim intResult As Integer 'request user really exit system login

IntResult=MsgBox (" if you really want to exit the system login, exit will not be able to launch the administrative system!" & VbCrLf _
& "Really exit?" , vbYesNo "login authentication")

If intResult=vbYes Then End
End Sub

Private Sub cmdOK_Click ()
The Static intLogTimes As Integer
Dim intChecked As an Integer, strName As String, strPassword As String
IntLogTimes=intLogTimes + 1 'calculation of landing number
If intLogTimes & gt; MaxLogTimes Then
MsgBox "do you have more than allow landing times!" & VbCr _
& "Application will end!" VbCritical, "login authentication
"
End
The Else
StrName=Trim (txtUserName. Text) 'for input user name
StrPassword=Trim (txtPassword. Text) 'input password
The legitimacy of the 'check user name and password, and according to check the return value to perform the corresponding operation
The Select Case Check_PassWord (strName, strPassword)
Case 0
MsgBox "& lt;" & StrName & amp; _
"> Is not a system user, please check whether the user name input right!" VbCritical, "login authentication
"TxtUserName. SetFocus
TxtUserName. SelStart=0
TxtUserName. SelLength=Len (txtUserName)
Case 1
MsgBox "password error, please log in again!" VbCritical, "login authentication
"TxtPassword=""
TxtPassword. SetFocus
Case 2 'password right
Unload Me
MsgBox "login is successful, will start the system program!" VbInformation, "login authentication
"MDIForm1. Show
In Case the Else
MsgBox "login verification is not normal! Please rerun the login procedure, "& amp; VbCrLf _
& "If you still can't normal login, please report the system administrator!" VbCritical, "login authentication
"
End the Select

End the If

CodePudding user response:

If has anything to do else?

CodePudding user response:

This logic problems

Since the login limit three times, the somebody else to restart the program does not again 3 times,,,

CodePudding user response:

refer to the second floor u011266608 response:
this logic problems

Since the login limit three times, the somebody else to restart the program does not again 3 times,,,

+ 1

Actually what login out three times, such as setting purely decoration, gratuitous added to the redundancy of the program.

If this is in order to "security", the error message is contradictory, behind you is equal to tell others "you guess wrong username"

Directly query the user name and password at the same time, there is in the login is successful, not in line with the user information and then refused to login.

Simplify the logic.