吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1984|回复: 2
收起左侧

[求助] vb 的if语句出现问题,多出了第三个elseif就会报错

[复制链接]
苦笑狗 发表于 2019-8-18 11:35
[Visual Basic] 纯文本查看 复制代码
Option Explicit
Dim A_1, A_2, A_3 As Integer
Rem 各个难度出现改变的概率
Private Sub Command2_Click()
List1.Clear
Label2.Caption = ""
End Sub

Private Sub Form_Load()
A_1 = 0.9
A_2 = 0.5
A_3 = 0.3
End Sub

Private Sub Label8_Click()
MsgBox "hhh我怎么会这么笨,第一次搞到了半夜才搞完" + Chr(10) + "后来忘记保存,程序又突然崩溃。哭泣。。", 1, "O(∩_∩)O哈哈~"
End Sub

Private Sub Label9_Click()
A_1 = Val(InputBox("简单部分", "有多少概率不改变 范围0~1 默认0.9"))
A_2 = Val(InputBox("普通部分", "有多少概率不改变 范围0~1 默认0.5"))
A_3 = Val(InputBox("放弃部分", "有多少概率不改变 范围0~1 默认0.3"))
End Sub

Private Sub text1_keypress(key As Integer)
Select Case key
    Case 49
    Label2.Caption = Label2.Caption + "A"
    Text1.Text = ""
    Case 50
    Label2.Caption = Label2.Caption + "B"
    Text1.Text = ""
    Case 51
    Label2.Caption = Label2.Caption + "C"
    Text1.Text = ""
    Case 53
    Label2.Caption = Label2.Caption + "D"
    Text1.Text = ""
    Case 48
    Label2.Caption = Mid(Label2.Caption, 1, Len(Label2.Caption) - 1)
    Text1.Text = ""
    Case 13
    Call Command1_Click
    Case 46
    Call Command2_Click
    End Select
End Sub

Private Sub Command1_Click()
List1.Clear
Dim n, i, cc, last As Integer 'last用于表示text4(最后一题),n用于记录输入的长度 i用于计数cc用于计数
Dim T_2, T_3 As Integer 'T_2,T_3用于记录text2和text3的内容
Dim hen, hena, henb As String 'hena用于记录第i+1个字符,henb用于随机答案,hen用于记录“ABCD”
hen = "ABCD"
cc = 0
n = Len(Label2.Caption)
If Text4.Text = "最后" Then
last = n
Else: last = Val(Text4.Text)
End If
T_2 = Val(Text2.Text)
T_3 = Val(Text3.Text)
For i = 0 To n - 1 Step 1
    hena = Mid(Label2.Caption, i + 1, 1)
hxh:
    Randomize
    henb = Mid(hen, Int(Rnd(4) + 1), 1)
    If (i + 1 <= Val(Text2.Text) And Rnd(1) >= A_1) Then
        If henb <> hena Then
        List1.AddItem CStr(i + 1) & henb & "X" & hena
        cc = cc + 1
        Else: GoTo hxh
        End If
    ElseIf i + 1 <= T_3 And Rnd(1) >= A_2 And i + 1 > T_2 Then
        If henb <> hena Then
        List1.AddItem CStr(i + 1) & henb & "X" & hena
        cc = cc + 1
        Else: GoTo hxh
        End If
    'ElseIf (i + 1 <= last) And (Rnd(1) >= A_3) And (i + 1 > T_3) Then
     '   If henb <> hena Then
      '  List1.AddItem CStr(i + 1) & henb & "X" & hena
       ' cc = cc + 1
        ''ElseIf henb = hena Then GoTo hxh
        'End If
        'If henb = hena Then GoTo hxh
	'问题出现在这里,多了这部分代码的话,然后输入超过16个程序会崩溃,求助
    Else: List1.AddItem CStr(i + 1) & hena
    End If

Next i
Label1.Caption = "共有:" & n & "个||" & cc & "个已经改变"
End Sub

Private Sub Text2_Click()
Text2.Text = ""
End Sub
Private Sub Text3_Click()
Text3.Text = ""
End Sub
Private Sub Text4_Click()
Text4.Text = ""
End Sub
Private Sub Text1_Click()
Text1.Text = ""
End Sub



网盘地址
求助大佬,在此先谢谢大佬

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 苦笑狗 发表于 2019-8-18 11:36
网盘怎么没了https://pan.baidu.com/s/102Jj9OznONIL8fRQxRJnpQ
...
 楼主| 苦笑狗 发表于 2019-8-18 11:46
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-27 04:28

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表