定义一个类型:
type UserType
Name as string*用户名长度
Psw as string*密码长度
end type
定义一个用户变量:
dim shared User as userType
再写一个密码的函数:
function Get.Psw$(YouString$)
sLen=len(YouString$)
for i=1 to slen
N%=asc(Mid$(YouString,i,1))
if N%>=128 then
Buf$=Buf$+chr$(N%-128)
else
Buf$=Buf$+chr$(N%+128)
endif
next
Get.Psw$=Buf$
end function
然后:
cls
Locate 1,1
ReInputUserName:
input "请输入用户名:";Tmp$
if Tmp$="" then goto ReInputUserName
user.Name=Tmp$
ReInputUserPsw:
input "请输入你的密码:";Tmp$
if Tmp$="" then goto ReInputUserPsw
user.Psw=Get.Psw(Tmp$)
这样,如果是第一次输入则保存到文件
如果不是第一次输入则从文件中取得用户数据验证密码正确性