Quantcast
Viewing all articles
Browse latest Browse all 27078

comparing Strings in and array to another string in a different array

im having alot of problems comparing strings. I tried two different ways which you will still see in this program. but i have the arrayString already populated in the program in a different sub. The user enters in there answer and it will populate that to a different array (answerArray) and then compares the two.

i have tried the breakpoint and input is populating into the answer string... but when it goes to compare it just doesnt compare them right so it wont award correctScoreShort 10 points... what error am i making?

thank you!




vbnet Code:
  1. Private Sub checkedButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkedButton.Click
  2.  
  3.             If answerTextBox.Text = String.Empty Then
  4.                 MessageBox.Show("You did not enter any answer", "ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error)
  5.             Else
  6.                 If questionsCountShort < 10 Then
  7.                 answerArrayString(questionsCountShort) = answerTextBox.ToString
  8.  
  9.       [B]          If answerArrayString(questionsCountShort).Contains(arrayString(questionsCountShort, 1)) Or _
  10.                     answerArrayString(questionsCountShort).Contains(arrayString(questionsCountShort, 2)) Or _
  11.                     answerArrayString(questionsCountShort).Contains(arrayString(questionsCountShort, 3)) Then
  12.                     'Is arrayString(questionsCountShort, 1) Or _
  13.                     '   answerArrayString(questionsCountShort) Is arrayString(questionsCountShort, 2) Or _
  14.                     '   answerArrayString(questionsCountShort) Is arrayString(questionsCountShort, 3)
  15. [/B]
  16.                     correctAnswerShort += 10S
  17.                     answerPictureBox = correctPictureBox[/B]                Else
  18.                     answerPictureBox = wrongPictureBox
  19.  
  20.                 End If
  21.                 hintCheckBox.Enabled = True
  22.                 hintCheckBox.Checked = False
  23.             Else
  24.                 MessageBox.Show("Your are done with you Current Test" & ControlChars.NewLine & _
  25.                                 "You may now text another test if you wish", "Done", MessageBoxButtons.OK)
  26.                 exitButton.Visible = True
  27.                 startOverButton.Visible = True
  28.                 startOverButton.Text = "Take Another Test"
  29.                 startOverButton.Enabled = True
  30.             End If
  31.             questionsCountShort += 1S
  32.             questionAskedLabel.Text = arrayString(questionsCountShort, 0)
  33.             questionNumberLabel.Text = questionsCountShort.ToString
  34.         End If
  35.  
  36.         answerTextBox.Text = String.Empty
  37.         answerTextBox.Focus()
  38.         startOverButton.Enabled = False
  39.         hintInfoLabel.Visible = False
  40.         exitButton.Visible = False
  41.     End Sub

Viewing all articles
Browse latest Browse all 27078

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>