如何编写这条程序?

e13653050049 2004-07-10 09:50:26
编写程序要求如下:
新建一个工程,添加两个窗体,在第一个窗体(Form1)上分别画标签框(Label1),
文本框(Text1),三个命令按钮:登录(Command1),重输(Command2),退出(Command3)。
程序运行后,在文本框(Text1)中输入密码,如果密码为:password,则显示第二个窗
体(Form2),否则,用MsgBox()函数提示密码错误,不能进入Form2。但如果连续三次输
入的密码都不对,则程序自动结速运行退出。
----------
各位可以给出详细的程序代码吗?
我是一个VB菜鸟兼自学者,还望各位多指教!
谢谢!
...全文
127 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
CrazyDogHH3 2004-07-11
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Static I As Integer '变量I统计输入错误口令的次数
If KeyCode = 13 Then '如果按下的键为回车键
If Ucase(Text1.Text) = "password" Then '如果口令为password
Form2.Show
ElseIf I = 0 Or I = 1 Then '如果口令错且错误次数少于2
I = I + 1
MsgBox "输入密码错误", vbInformation, "提示"
Text1.SelStart = 0 '反白显示文本框有密码区域
Text1.SelLength = Len(Text1.Text)
Else '如果口令错且错误次数等于2(即已经错了两次,现在是第三次错)
End '退出程序
End If
End If
End Sub
CrazyDogHH3 2004-07-11
  • 打赏
  • 举报
回复
楼上的这样抄二楼的CODE不厚道啊~~
taocsdn 2004-07-11
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Static intNum As Integer
If Text1.Text <> "password" Then
If intNum = 2 Then
MsgBox "三次输入错误密码!", vbInformation, "提示"
End
Else
intNum = intNum + 1
MsgBox "输入密码不正确!", vbInformation, "提示"
End If
Else
Form2.Show
End If
End Sub
rexyudl 2004-07-10
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Static intNum As Integer
If Text1.Text <> "password" Then
If intNum = 2 Then
MsgBox "三次输入错误密码!", vbInformation, "提示"
End
Else
intNum = intNum + 1
MsgBox "输入密码不正确!", vbInformation, "提示"
End If
Else
Form2.Show
End If
End Sub
hepz 2004-07-10
  • 打赏
  • 举报
回复
dim a,v
private sub command1_click
a=0
re:
if a>=3 then
end
end if
if text1.text="password" then
form1.hide
form2.show
else
v=msgbox("your password is wrong!",vbyescancel,"msgbox")
if v=vbyes then
a=a+1
goto re
else
end
end if
end if
end sub

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧