Solved

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

Posted on 2014-03-07
2
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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