?
Solved

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

Posted on 2014-03-07
2
Medium Priority
?
244 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 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