按钮单击visual basic时,文本框会更改

时间:2014-08-24 06:22:34

标签: vba

需要帮助,当我点击绘图按钮时,文本框(txt2 txt3 txt4)变为0而不是我放的数字。继承我的代码

Public Class Form2     Dim RndGen作为新的随机     Dim N7,N5,N6 As Integer     Dim N2,N3,N4 As Integer

Private Sub draw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles draw.Click
    txt2.Text = N2
    txt3.Text = N3
    txt4.Text = N4
    txt5.Text = N5
    txt6.Text = N6
    txt7.Text = N7

    txt2.Focus()
    N5 = RndGen.Next(1, 10)
    N6 = RndGen.Next(1, 10)
    N7 = RndGen.Next(1, 10)

    If N2 = N5 Or N3 = N6 OrElse N4 = N7 Then
        MessageBox.Show("CONGRATS")
    End If


End Sub

结束班

Windows Form

1 个答案:

答案 0 :(得分:0)

从你公开的代码片段中我认为N2应该读取txt2中的值而不是设置它。我觉得你实际上用零重置了文本框。