0

please help!!!
i have a datagridview on my form with customers info which is linked to my database. i want to execute a line of code based on the information in one of the columns in the datagridview??? for example i have a datetime column which stores dates(and maybe time) i want to use an if statement(or any code) to compare the date the customer entered. if its today then my code will execute!!


please help me on how to do this
thanks a lot in advance
God bless

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by obwills
1

hello!
try this code

dim i as integer
for i = 0 to datagridview1.rows.count-1 
 if datagridview1.item(2,i).value.tostring =   Now.Date.ToString() then 
 'now here put your code you want to execute
endif
next

Hope this will helps you if yes then please mark your thread solved and vote me up :)

Regards

0

thanks
but there was an error, it says "i tried to use an object without providing an instance of the object."for "if datagridview1.item(2,i).value.tostring = Now.Date.ToString() then"

1

ok well use this , may be this will solve your prob

dim i as integer
dim a as string 
for i = 0 to datagridview1.rows.count-1 
a = datagridview1.item(2,i).value.tostring()
 if a =   Now.Date.ToString() then 
 'now here put your code you want to execute
endif
next

Regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.