Help! I need to know what I am doing wrong!

Alex

New member
Joined
Jan 27, 2006
Messages
2
Programming Experience
Beginner
I am trying to work out a solution.
Question- What is the value in txtOutput after the following code is executed if strExampleValue is set to: a."XOX" b."XXX" c."OOX"

Private Sub btnOutput_Click (...
Dim strExampleValue As String
strExampleValue = "XOX" 'or the other value

If (strExampleValue = "XXX") Then
txtOutput.Text = "Choice 1"
ElseIf (strExampleValue = "OOO") Then
txtOutput.Text = "Choice 2"
ElseIf (strExampleValue = "OXO") Then
txtOUtput.Text = "Choice 3"
Else
txtOutput.Text = "Choice 4"
End If
End Sub

On my form i have created a txtbox, button, and another textbox for output. When I enter info from question XOX i get choice 4 for output but i get the same for all others. I don't know if I have set up my form correctly. I need some advice if I am doing correctly.
 
you could try a Select Case statement instead...

VB.NET:
Select Case StrExampleValue
Case StrExampleValue = "xxx"
txtoutput.text = "Choice 1"

and so on until you entered all the possible permutations then at the bottom of yuor select case statement...

VB.NET:
Case Else
txtoutput.text = "Choice 4"
End Select
 
a."XOX" Choice 4 (else)
b."XXX" Choice 1
c."OOX" Choice 4 (else)

If the code above is what you run when inputting strings in your input textbox, if will always return 'choice 4' since you always check 'strExampleValue'. If your input textbox is named txtInput, try getting the value for instance like this:
strExampleValue = txtInput.Text
 
Back
Top