用易语言写一个账号管理系统
时间: 2023-06-27 13:02:25 浏览: 219
好的,以下是一个基本的账号管理系统的易语言代码:
```
'定义变量
Dim account, password As String
Dim accounts(50), passwords(50) As String
Dim count As Integer
'打开文件并读取账号信息
Open "account.txt" For Input As #1
count = 0
While Not EOF(1)
Input #1, accounts(count), passwords(count)
count = count + 1
Wend
Close #1
'主菜单函数
Function MainMenu() As Integer
Cls
Print "1. 注册账号"
Print "2. 登录账号"
Print "3. 退出"
Print
Input "请输入选项:", MainMenu
End Function
'注册账号函数
Sub Register()
Cls
Input "请输入账号:", account
Input "请输入密码:", password
accounts(count) = account
passwords(count) = password
count = count + 1
Open "account.txt" For Append As #1
Write #1, account, password
Close #1
Print "注册成功!"
Sleep 1000
End Sub
'登录账号函数
Sub Login()
Cls
Input "请输入账号:", account
Input "请输入密码:", password
For i = 0 To count - 1
If accounts(i) = account And passwords(i) = password Then
Print "登录成功!"
Sleep 1000
Exit Sub
End If
Next
Print "账号或密码错误,请重新输入!"
Sleep 1000
End Sub
'主程序
While True
Select Case MainMenu()
Case 1
Register()
Case 2
Login()
Case 3
End
End Select
Wend
```
这个账号管理系统可以让用户注册账号并保存到文件中,以便下次登录时使用。用户输入账号和密码进行登录,系统会检查账号和密码是否匹配。如果匹配成功,系统会提示登录成功,否则提示账号或密码错误。
阅读全文