By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

Displaying Results from Comparing texts from 2 forms

P: 1
Hi good day guys i would just like to seek some help regarding my problem here in VB.NET. I have this program that if the text in the textbox is equal to the text in the label of the previous form it will add 1 for each correct answer but instead it always shows zero (0) (last form) and not showing the results that I want. Here is my code guys I hope you can help me with this problem thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. Imports System.Convert
  2. Imports System.IO
  3. Public Class Form3
  4.  
  5.     Public frm2 As Form2
  6.     Public frm4 As Form4
  7.  
  8.     Public Sub New1(ByVal callerInstance As Form2)
  9.  
  10.         InitializeComponent()
  11.  
  12.         ' save the instance of the Me variable passed to this constructor
  13.         frm2 = callerInstance
  14.     End Sub
  15.     Public Sub New2(ByVal callerInstance As Form4)
  16.  
  17.         InitializeComponent()
  18.         ' save the instance of the Me variable passed to this constructor
  19.         frm4 = callerInstance
  20.     End Sub
  21.  
  22.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  23.         Dim frm2 As Form2 = Form2
  24.         Dim frm4 As Form4 = Form4
  25.         frm2 = New Form2
  26.         frm4 = New Form4
  27.  
  28.         'program execution proper
  29.  
  30.         Dim lbl3 As Integer = CInt(frm4.Label3.Text)
  31.         lbl3 = CInt(frm4.Label3.Text)
  32.         Dim Label22 As New Label
  33.         If frm2.Label22.Text = TextBox1.Text Then
  34.             lbl3 = CInt(lbl3) + 1  
  35.  
  36.             Dim Label24 As New Label
  37.         ElseIf (TextBox2.Text = Form2.Label24.Text) Then
  38.             lbl3 = CInt(lbl3) + 1
  39.  
  40.             Dim Label26 As New Label
  41.         ElseIf (frm2.Label26.Text = TextBox3.Text) Then
  42.             lbl3 = CInt(lbl3) + 1
  43.  
  44.             Dim Label28 As New Label
  45.         ElseIf (frm2.Label28.Text = TextBox4.Text) Then
  46.             lbl3 = CInt(lbl3) + 1
  47.             Dim Label30 As New Label
  48.         ElseIf (frm2.Label30.Text = TextBox5.Text) Then
  49.             lbl3 = CInt(lbl3) + 1
  50.             Dim Label32 As New Label
  51.         ElseIf (frm2.Label32.Text = TextBox6.Text) Then
  52.             lbl3 = CInt(lbl3) + 1
  53.             Dim Label34 As New Label
  54.         ElseIf (frm2.Label34.Text = TextBox7.Text) Then
  55.             lbl3 = CInt(lbl3) + 1
  56.             Dim Label36 As New Label
  57.         ElseIf (frm2.Label36.Text = TextBox8.Text) Then
  58.             lbl3 = CInt(lbl3) + 1
  59.             Dim Label38 As New Label
  60.         ElseIf (frm2.Label38.Text = TextBox9.Text) Then
  61.             lbl3 = CInt(lbl3) + 1
  62.             Dim Label40 As New Label
  63.         ElseIf (frm2.Label40.Text = TextBox10.Text) Then
  64.             lbl3 = CInt(lbl3) + 1 
  65.  
  66.             frm4.Show()
  67.         Else
  68.             lbl3 = CInt(lbl3) + 1 'Int((lbl3 = Convert.ToInt64(lbl3)) + 1)
  69.             frm4.Show()
  70.         End If
  71.  
  72.  
  73.         If frm4 IsNot Nothing Then
  74.             frm4.Show() 'Show Second Form  
  75.             Me.Hide()
  76.         End If
  77.  
  78.     End Sub
  79.  
  80.  
  81. End Class
Feb 20 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.