Link to home
Start Free TrialLog in
Avatar of Yasmin Rodriguez
Yasmin Rodriguez

asked on

IF STATEMENT ISSUE

This is my code for a trouble shooting system: The problem is that because there is two ifs with the same statement it won't work. However I know I could change it to a select case format however that's were I'm uncertain and how to proceed
This isn't the finished version I am working in Vb.net :
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim problem As String
        TextBox1.Focus()
        problem = TextBox1.Text
        If TextBox1.Text = "bad" Then
            Label2.Text = "Sorry but to start off with what make is your phone?"
        ElseIf TextBox1.Text = "good" Then
            Label2.Text = "Thats good to hear but to start off with what make is your phone?"
        ElseIf TextBox1.Text = " i dont know" Then
            Label2.Text = " Okay. To start off with what make is your phone?"
        End If
        TextBox1.Text = ""



        If problem = "iphone" Then
            Label2.Text = " What problems are you having with your iphone,?" + Environment.NewLine + "is your problem related to screen"
        ElseIf problem = "android" Then
            Label2.Text = " What problems are you having with your android device," + Environment.NewLine + "is your problem related to screen "
        ElseIf problem = "blackberry" Then
            Label2.Text = "What problems are you having with your blackberry device" + Environment.NewLine + "Is your problem related to screen" + Environment.NewLine + " Please enter yes or no to the following questions!"
        End If


        Dim count (music) As String
        count (o) = "Has the screen got wet in the last 24 hours?"
        count(1) = "Is the screen of the device cracked?"
        count(2) = "Is your screen slow and crashing?"
        count(3) = " Is your touch screen not responding"
        count(4) = "Do you have sufficent funds in your account  send text messages"
        count(5) = "Are you able to recieve text messages and send texts?"
        count (devil) = " Do you have suffiencent funds in your account?"
        count(7) = "Are you connected to wifi or have sufficient funds to use data"

        TextBox1.Focus()
        If problem = "yes" Then
            Label2.Text = count (o)
        If problem = "yes" Then
            Label2.Text = "Try removing the back casing and wiping the back of the phone"
            If problem = "no" Then
                Label2.Text = count(1)
                If problem = "yes" Then
                    Label2.Text = " You will need to get your device's screen fixed for continued usage"
                    If problem = "no" Then
                        Label2.Text = count(2)
                        If problem = "yes" Then
                            Label2.Text = " Close the apps that are not in use and also try and turn your phone off and back on again"
                            If problem = "no" Then
                                Label2.Text = count(3)
                                If problem = "yes" Then
                                    Label2.Text = "The best solution is to take your phone to the local care centre as your LCD may be broken if there is no response "
                                    If problem = "no" Then
                                        Label2.Text = "If you have any more screen related queries you will need to contact 03001234567"
                                    ElseIf problem = "no" Then
                                        Label2.Text = "Is your problem related to text messages?"
                                        If problem = "yes" Then
                                            Label2.Text = count(4)

                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If

                End If
            End If
        End If
        End If
    End Sub

    Private Sub Label2_Click(sender As System.Object, e As System.EventArgs) Handles Label2.Click
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Label2.Text = "Welcome to the trouble shooting system. How are you doing today?"
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Label2.Text = "Welcome to the trouble shooting system. How are you doing today?"
    End Sub
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yasmin Rodriguez
Yasmin Rodriguez

ASKER

Firstly thank you for your comment. However i dont understand. How would i lay it out would i write
if true yes
or something else of that sort
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is how i want the program to be run
if the user says yes the problem is screen related to displays count(0)
if its says yes to the question in count(0) the program gives the user a solution
alternatively if the users says no to count(0) it moves to count(1)
if it says no it isnt screen related it moves to the text message questions
OK.
So ask the question you want inside the if statement by displaying a dialog with the question on it.  (Or move to another screen like a 'wizard' style)
Please post what you will be doing / what the advice was especially if different to what I suggested here
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm displaying my answers in a select case format which means I would like to delete this question know however I'm very grateful for the help
>>I'm displaying my answers in a select case format
OK, but how does that work with your original logic.  You had if the response is 'yes' then I want to do X but for another version of 'yes' instead do Y but for another version of 'yes' do Z.  
select
  case 'yes'
  case 'yes'
  case 'yes'
end select
doesn't work.

Note I first said you needed to get the logic of what is to be done when before you could start writing the code.
The logic of what is to be done must be in place before attempting to write any code.  The code from David Johnson is an example of one possible way to do it.