【发布时间】:2014-03-22 15:05:06
【问题描述】:
大家好,我想就我在 VB.NET 中遇到的问题寻求一些帮助。我有这个程序,如果文本框中的文本等于前一个表单的文本框中的文本,它将为每个正确答案加 1,但它始终显示零(0)(最后一个表单)并且不显示结果我想要。这是我的代码家伙,我希望您能帮助我解决这个问题,谢谢。
Imports System.Convert
Imports System.IO
Public Class Form3
Private frm1 As Form1
Private frm4 As Form4
Public Sub New1(ByVal callerInstance As Form1)
InitializeComponent()
' save the instance of the Me variable passed to this constructor
frm1 = callerInstance
End Sub
Public Sub New2(ByVal callerInstance As Form4)
InitializeComponent()
' save the instance of the Me variable passed to this constructor
frm4 = callerInstance
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm1 As Form1 = Form1
Dim frm4 As Form4 = Form4
frm1 = New Form1
frm4 = New Form4
'program execution proper
Dim lbl3 As Integer = CInt(frm4.Label3.Text)
lbl3 = CInt(frm4.Label3.Text)
Dim Label22 As New Label
If frm1.TextBox2.Text = TextBox1.Text Then
lbl3 = CInt(lbl3) + 0 'if(integer.tryparse, lbl3) then lbl3 += 1
Dim Label24 As New Label
If Not frm1.TextBox4.Text = TextBox2.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label26 As New Label
If Not frm1.TextBox6.Text = TextBox3.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label28 As New Label
If Not frm1.TextBox8.Text = TextBox4.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label30 As New Label
If Not frm1.TextBox10.Text = TextBox5.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label32 As New Label
If Not frm1.TextBox12.Text = TextBox6.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label34 As New Label
If Not frm1.TextBox14.Text = TextBox7.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label36 As New Label
If Not frm1.TextBox16.Text = TextBox8.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label38 As New Label
If Not frm1.TextBox18.Text = TextBox9.Text Then
lbl3 = CInt(lbl3) + 0
Dim Label40 As New Label
If Not frm1.TextBox20.Text = TextBox10.Text Then
lbl3 = CInt(lbl3) + 0 'frm4.Label3.Text = (frm4.Label3.Text) + 1
frm4.Show()
Me.Hide()
Else
lbl3 = CInt(lbl3) + 1
frm4.Show()
Me.Hide()
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
If frm4 IsNot Nothing Then
frm4.Visible = False
frm4.Show(Me) 'Show Second Form
Me.Hide()
End If
End Sub
End Class
【问题讨论】:
-
@ElektroStudios 嗨,先生,您可以批评,但请确保它是建设性的,而不是犯规:) 无论如何,帮助而不是指责会更好.. 顺便说一句,谢谢你的输入:)
-
@OSKM 不要这么粗鲁,我是在礼貌地问。我的第一个帖子没有答案,所以它正好为如何获得帮助提供一种方式。谢谢您关心的方式。
-
道歉 - 无意粗鲁,只是提请注意其他两个问题,以免一些可怜的人浪费他们宝贵的时间重复已经提出的建议,我几乎在您的第二篇文章中这样做了,然后链接到第一个被添加了!作为建议,您最好保留相同的用户名,并在新问题中突出显示之前的问题,说明他们的答案为何不充分。
-
一点 - 所有
Dim-ed 标签的目的是什么 - 它们似乎没有在代码示例中使用 - 它们是否在其他地方使用?