Comparing a Variable with 'text'

hey guys, this is simple question im sure, but i cant figure why this wont work:

ticketStatus = Me.CheckInTicketList.CurrentRow.Cells(Me.Status.Index).Value()
        If ticketStatus = "active" Then
           code
        Else : MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Else
            MessageBox.Show("Error - This Ticket is not Active, this ticket might already been used or is considered invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
        End If

it keeps give the messagebox. why? maybe im to used to pascal?
aborg85Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
Hi aborg85,

you have 1 IF, 2 ELSE, 2 ENDIF! That doesn't match! The syntax is:

 If ticketStatus = "active" Then
           code
 Else
        MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If


Cheers!
0
aborg85Author Commented:
Sry i did a mistake when copying and pasteing

Dim ticketStatus As String
ticketStatus = Me.CheckInTicketList.CurrentRow.Cells(Me.Status.Index).Value()
        If ticketStatus = "active" Then
            Dim Name As String
            Dim Surname As String

            If Me.CheckInTicketList.RowCount > 0 Then
                code
            Else : MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Else
            MessageBox.Show("Error - This Ticket is not Active, this ticket might already been used or is considered invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
        End If
    End Sub
0
Éric MoreauSenior .Net ConsultantCommented:
Which messagebox do you always see? what is the value of ticketStatus? Notice that the comparison is case sensitive.

also change:
           Else : MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)

to:
           Else
                MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

aborg85Author Commented:
i always see this:

MessageBox.Show("Error - This Ticket is not Active, this ticket might already been used or is considered invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

ticketstatus is a part of datagridview and is textboxcolumn.

I ve also arranged this piece as  u suggested,  Else : MessageBox.Show("There are No Ticket Under this PNR to check In!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
0
Éric MoreauSenior .Net ConsultantCommented:
and what is the value of ticketStatus ? You will find the exact value like this:

ticketStatus = Me.CheckInTicketList.CurrentRow.Cells(Me.Status.Index).Value()
message box.show(">>" & ticketStatus & "<<")
        If ticketStatus = "active" Then

rember that the comparison is case sensitive.
0
aborg85Author Commented:
infact its giving me "Active  ", and changed  the code to

if ticketstatus = "Active  " then

but still same messagebox
0
Éric MoreauSenior .Net ConsultantCommented:
what do you get if you do :
message box.show(">>" & ticketStatus.trim.toupper & "<<")

and

 If ticketStatus.trim.toupper = "ACTIVE" Then
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aborg85Author Commented:
emoreau, YOUR A STAR!

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.