只需生成答案

时间:2013-06-11 13:33:13

标签: vb.net function random

Public Class Form1
Dim num1 As Integer = CInt(Int((10 * Rnd()) + 1))
Dim num2 As Integer = CInt(Int((10 * Rnd()) + 1))
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load



End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    ' It is meant to display the question on textbox2.text, not the answer
    TextBox2.Text = num1 * num2
End Sub

Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
    If TextBox1.Text = num1 * num2 Then
        Label2.Text = "Correct!!11"
    Else
        Label2.Text = "Incorrect, sorry about that"
    End If
End Sub

End Class

我希望textbox2显示类似“5 * 5”的问题,但它只显示“25”

1 个答案:

答案 0 :(得分:2)

您正在将值分配给文本框,作为num1和num2的乘积。您需要连接像这样的字符串值

TextBox2.Text = num1 & " * " & num2