Solved

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

Posted on 2014-03-07
2
231 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

680 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