Solved

If statment - if value does not = 0 and value dpes nto = 0

Posted on 2014-03-07
2
227 Views
Last Modified: 2014-03-07
I am trying to add some value to my database only if but my values don't contain 0 (zero)

Currently my code looks like this

  If Convert.ToInt32(sessionh05.Split("/")(2)) <> "0" And Convert.ToInt32(sessiona05.Split("/")(2)) <> "0" Then
                    inserttodaysmatchesintodb(dv2.Row.Item("Kickofftime"), dv2.Row.Item("hometeam") & " V " & dv2.Row.Item("awayteam"), Session("hftover05"), Session("aftover05"), Session("vftover05"), Session("hftover15"), Session("aftover15"), Session("vftover15"), Session("hftover25"), Session("aftover25"), Session("vftover25"))
                End If

Open in new window


My issue is if only 1 of the values contain zero it does nto add it but it should be only if BOTH values contain zero.

I have performed an output to make sure i am getting value back using this code

    test123.text += "ht :" & sessionh05.Split("/")(2) & " at: " & Convert.ToInt32(sessiona05.Split("/")(2)) & "<br>"

Open in new window


And i get the following results

ht :0 at: 0
ht :0 at: 47
ht :0 at: 0
ht :0 at: 0
ht :23 at: 0
ht :0 at: 0
ht :0 at: 0
ht :0 at: 0

as you can see ht :0 at: 47 should be added and ht :23 at: 0 should be added but its not.

Can anyone help with my logic
0
Comment
Question by:runnerjp2005
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39912046
Try using OR instead of AND:

  If Convert.ToInt32(sessionh05.Split("/")(2)) <> "0" Or Convert.ToInt32(sessiona05.Split("/")(2)) <> "0" Then
                    inserttodaysmatchesintodb(dv2.Row.Item("Kickofftime"), dv2.Row.Item("hometeam") & " V " & dv2.Row.Item("awayteam"), Session("hftover05"), Session("aftover05"), Session("vftover05"), Session("hftover15"), Session("aftover15"), Session("vftover15"), Session("hftover25"), Session("aftover25"), Session("vftover25"))
                End If

Open in new window

0
 

Author Comment

by:runnerjp2005
ID: 39912059
It worked
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now