我正在制作故障排除程序。到目前为止,我有以下代码:
{{1}}
当您点击“是”或“否”按钮时,如何将标签更改为另一个问题
答案 0 :(得分:0)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'currentq = 0 here , so it shows the next question
LoadNextQuestion()
End Sub
Public Sub LoadNextQuestion()
If currentq = 0 Then
Label1.Text = Q1
ElseIf currentq = 1 Then
Label1.Text = Q2
ElseIf currentq = 2 Then
Label1.Text = Q3
ElseIf currentq = 3 Then
Label1.Text = Q4
ElseIf currentq = 4 Then
Label1.Text = Q5
ElseIf currentq = 5 Then
Label1.Text = Q6
ElseIf currentq = 6 Then
Label1.Text = Q7
End If
End Sub
现在在no / yes按钮中:
没有按钮:
'Loads next question
currentq += 1
LoadNextQuestion()
是按钮:
Controls.Clear()
InitializeComponent()
Me.Hide()
Form1.Show()
答案 1 :(得分:0)
尝试更像这样的东西......
Public Class speakers
Dim currentq As Integer
Dim questions() As String = {
"Does sound play?",
"Has the sound got too much bass or treble?",
"Is the sound too loud or quiet?",
"Is sound distorted?",
"a",
"b",
"c",
"d"
}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Button4.PerformClick()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
currentq = currentq + 1
If (currentq < questions.Length) Then
Label1.Text = questions(currentq)
Else
MessageBox.Show("End of questions reached.")
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
currentq = -1
Button1.PerformClick()
End Sub
End Class