标题:什么毛病呢(初学VB的人的求助)
只看楼主
yexuxiang
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-4-2
 问题点数:0 回复次数:2 
什么毛病呢(初学VB的人的求助)

Private Sub Command1_Click() Dim name, pass, x1, y1, x2, y2 name = InputBox("Input your name") pass = InputBox("Input your pass") x1 = "yexuxiang" y1 = "123456" x2 = "QQ" y2 = "342462561" If name = x1 And pass = y1 Then _ MsgBox ("welcome your!") And Form1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\07568.jpg")

Else: If name = x2 And pass = y2 Then _ MsgBox ("yes,good!") And Form1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\2004123119369241.gif")

End Sub 上面的代码运行时总是出现"ELSE没有IF"的错误提示,请问是什么意思呀,到底哪里出错了呢,书上都是这么写的代码呀?急死人了,又没有MSDN

搜索更多相关主题的帖子: pass name 毛病 And 
2005-04-02 23:12
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
不仅没有IF而且没有End IF。

IF [条件表达式] Then
       [代码]

else
       [代码]
End IF

以上为正确的结构Else那里没有:号。
2005-04-02 23:21
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
得分:0 
Private Sub Command1_Click()
Dim name, pass, x1, y1, x2, y2
    name = InputBox("Input your name")
    pass = InputBox("Input your pass")
    x1 = "yexuxiang"
    y1 = "123456"
    x2 = "QQ"
    y2 = "342462561"
    If name = x1 And pass = y1 Then
          MsgBox ("welcome your!")
          Form1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\07568.jpg")
    ElseIf name = x2 And pass = y2 Then
          MsgBox ("yes,good!")
          Form1.Picture = LoadPicture("C:\Documents and Settings\Administrator\My Documents\My Pictures\2004123119369241.gif")
    End If
End Sub

天津网站建设 http://www./
2005-04-03 12:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-14677-1-1.html




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

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