| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 716 人关注过本帖
标题:这个代码怎么修改
只看楼主 加入收藏
向钱看
Rank: 2
等 级:论坛游民
帖 子:46
专家分:65
注 册:2010-3-18
结帖率:57.14%
收藏
 问题点数:0 回复次数:5 
这个代码怎么修改
写一个登录器,帐号110 密码120
以下是我自己写的代码
Private Sub Command1_Click()
If s = 110 Then t1 = "登陆成功"
If s <> 110 Then t1 = "帐号或密码错误"
If z = 120 Then t2 = "登陆成功"
If z <> 120 Then t2 = "帐号或密码错误"
Text1.Text = t1
Text2.Text = t2
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
Command1.Caption = "确定"
Command2.Caption = "注销"
Command3.Caption = "退出"
Frame1.Caption = "帐号"
Frame2.Caption = "密码"
Frame3.Caption = "作者:黑夜里的黑猫"

Form1.Caption = "QQ2010"
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Frame4_DragDrop(Source As Control, X As Single, Y As Single)
Frame = t2
End Sub
为什么输入正确,但是还显示帐号或密码错误??谁能帮忙改下
搜索更多相关主题的帖子: 代码 
2010-04-24 09:05
wei855198
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:228
专家分:944
注 册:2009-4-24
收藏
得分:0 
乱糟糟的,建议你随便找本书看看。
简单分析一个:
你输入的数据输入到什么地方了?Text控件?但是并没有传给s和z,如何判断你输入正确?
貌似你这段代码没有执行什么操作

护肤小店 http://mina2010.
靓装小店 http://liangliyizu2010.
2010-04-24 11:30
向钱看
Rank: 2
等 级:论坛游民
帖 子:46
专家分:65
注 册:2010-3-18
收藏
得分:0 
回复 2楼 wei855198
新学VB  才几天
2010-04-24 12:11
gg171131862
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-4-24
收藏
得分:0 
Private Sub Command1_Click()
Dim s As Integer, z As Integer
s = Val(Text1.Text)
z = Val(Text2.Text)
If s = 110 And z = 120 Then
Text1.Text = "登陆成功"
ElseIf s <> 110 Or z <> 120 Then
Text1.Text = "帐号或密码错误"
End If
End Sub
2010-04-24 18:21
wei855198
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:228
专家分:944
注 册:2009-4-24
收藏
得分:0 
Private Sub Command1_Click()
dim s as integer,z as integer
dim t1 as string,t2 as string
s=val(text1.text)
z=val(text2.text)
If s = 110 Then t1 = "登陆成功"
If s <> 110 Then t1 = "帐号或密码错误"
If z = 120 Then t2 = "登陆成功"
If z <> 120 Then t2 = "帐号或密码错误"
Text1.Text = t1
Text2.Text = t2
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
Command1.Caption = "确定"
Command2.Caption = "注销"
Command3.Caption = "退出"
Frame1.Caption = "帐号"
Frame2.Caption = "密码"
Frame3.Caption = "作者:黑夜里的黑猫"

Form1.Caption = "QQ2010"
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Frame4_DragDrop(Source As Control, X As Single, Y As Single)
Frame = t2
End Sub

简单起见,在源代码上修改了下,不过建议你从书上找个登录的例子看看

[ 本帖最后由 wei855198 于 2010-4-26 14:46 编辑 ]

护肤小店 http://mina2010.
靓装小店 http://liangliyizu2010.
2010-04-26 08:53
zzy_420
Rank: 4
等 级:业余侠客
威 望:2
帖 子:78
专家分:217
注 册:2009-3-26
收藏
得分:0 
Private Sub Command1_Click()
Dim s As Integer, z As Integer
s = Val(Text1.Text)
z = Val(Text2.Text)
If s = 110 And z = 120 Then
Text1.Text = "登陆成功"
ElseIf s <> 110 Or z <> 120 Then
Text1.Text = "帐号或密码错误"
End If
End Sub
至少献给变量赋值后才能比较啊
2010-04-27 10:59
快速回复:这个代码怎么修改
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032895 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved