VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,389 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,562 people online right now. Registration is fast and FREE... Join Now!




IF ITEM.string ("") <> then ?

 

IF ITEM.string ("") <> then ?

MoistFist

2 Jul, 2009 - 07:33 AM
Post #1

D.I.C Head
**

Joined: 2 Jun, 2009
Posts: 76


My Contributions
When i state this IF statment, i am querying from a SQL DB, and after the vaulue equals true it does stuff... is the = "" mean that it will always bring a value,



CODE
If dr2.Item("DischargeDateTime").ToString = "" And dr2.Item("AdmitDateTime").ToString = "" Then
                    'Send an A03 message '
                    sMessage = ""


User is offlineProfile CardPM
+Quote Post


modi123_1

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 07:48 AM
Post #2

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
Ah.. what? the

CODE

dr2.Item("DischargeDateTime").ToString = ""


means if dr2.Item("DischargeDateTime").ToString equals an empty string...
User is offlineProfile CardPM
+Quote Post

MoistFist

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 09:43 AM
Post #3

D.I.C Head
**

Joined: 2 Jun, 2009
Posts: 76


My Contributions
CODE
If dr2.Item("DischargeDateTime").ToString <> "" And dr2.Item("AdmitDateTime").ToString <> "" And "" <= "200800000000" Then
                    'patien is showing a dishcharge dat but NO Admit date
                    'send A03
                    EPRDishDate = CType(dr2.Item("DischargeDateTime").ToString, DateTime)
                    EPRAdmitDate = CType(dr2.Item("AdmitDateTime").ToString, DateTime)
                    sMessage = ""


so what i want is to only write dishchargedatetimes with a date of 2008 and lower, how can i do that?

This post has been edited by MoistFist: 2 Jul, 2009 - 09:44 AM
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 10:00 AM
Post #4

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
Easy - convert "dr2.Item("DischargeDateTime")" to a datetime and use that object's property for .Year to set up the if statement

<datetime_object>.year <= 2008
User is offlineProfile CardPM
+Quote Post

CamoDeveloper

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 11:39 AM
Post #5

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
Since you're using strings, you don't need to convert it to a date to compare it. Try something like this:
CODE

If dr2.Item("DischargeDateTime").ToString <= "2008" Then
    'Code Here
End If

Also, why don't you just filter it by date in your query?

~Camo
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 11:44 AM
Post #6

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
Camo - that won't work. s/He is converting it to a string so it will try and evaluate a full date time string is less than or equal to another string.

ex: "01/01/1900 12:00:00" <= "2008
User is offlineProfile CardPM
+Quote Post

CamoDeveloper

RE: IF ITEM.string ("") <> Then ?

2 Jul, 2009 - 11:50 AM
Post #7

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
Ahh, I missed the DateTime part...Yeah, what Modi said will work, my bad on the confusion.

~Camo
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:40PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month