如何在VB.NET中自动显示文本框的值

问题描述:

我有3个文本框,即NQ,TPQ和ET。 NQ允许用户输入指定数量的问题(1到100),TPQ显示每个问题的时间及其给定的30秒,ET计算并显示指定问题集的总时间。在提供值之前,TPQ不会在文本框中显示每个问题的时间,然后将时间显示为30秒。我希望一旦用户在NQ文本框中指定问题的数量就自动完成。



2.我想计算总计为指定数量的问题。



以下是我在第一部分尝试的内容。



我尝试了什么:



I have 3 textboxes, namely NQ, TPQ and ET. NQ allows the user to enter a specified number of question (1 to 100), TPQ display the time per each question and its given as 30seconds, the ET calculate and display the total time for the specified set of question. TPQ doesn't display the Time per question in it textbox until a value is provided, then it displays the Time as 30seconds. please I want it to be done automatically as soon as a user specifies the number of question in the NQ textbox.

2. I want to calculate the to the Total for a specified number of questions.

below is what I have tried for the first part.

What I have tried:


Private Sub Course_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles Course.SelectedIndexChanged
        If Course.Text = "Microsoft" Then
            Type.SelectedItem = ("Windows Server")
            Category.SelectedItem = ("All Windows Server Exams")
        ElseIf Course.Text = "Cisco Associate" Then
            Type.SelectedItem = ("Cisco CCNA")
            Category.SelectedItem = ("All CCNA Exams")
        ElseIf Course.Text = "Cisco Professional" Then
            Type.SelectedItem = ("Cisco CCNP")
            Category.SelectedItem = ("All CCNP Exams")
        ElseIf Course.Text = "CompTIA Hardware" Then
            Type.SelectedItem = ("CompTIA A+")
            Category.SelectedItem = ("CompTIA A+")
        ElseIf Course.Text = "CompTIA Security" Then
            Type.SelectedItem = ("CompTIA Sec+")
            Category.SelectedItem = ("CompTIA Sec+")
        End If
    End Sub

    Private Sub NQ_TextChanged(sender As Object, e As EventArgs) Handles NQ.TextChanged
        If NQ.Text < 100 Or NQ.Text = 0 Then
        ElseIf NQ.Text > 100 Then
            MessageBox.Show("Maximum question is 100")
        ElseIf IsNumeric(NQ.Text) Then
        End If

    End Sub

    Private Sub TPQ_TextChanged(sender As Object, e As EventArgs) Handles TPQ.TextChanged
        Dim seconds As Double
        seconds = 30
        TPQ.Text = seconds & " seconds"
    End Sub

    Private Sub ET_TextChanged(sender As Object, e As EventArgs) Handles ET.TextChanged

    End Sub


为什么TPQ在用于显示时有一个文本更改处理程序?



如果NQ的值有效,则从NQ的文本更新TPQ更改。
Why does TPQ have a text changed handler when it is being used for "display"?

Update TPQ from NQ's text changed, if NQ's value is valid.