Showing posts with label expression. Show all posts
Showing posts with label expression. Show all posts

Wednesday, March 28, 2012

Subtracting Date in VB.Net

Need Help!

How do I write the following expression for my project limiting the number of entries on my datagrid by 30 days from Now():

<!--

SELECT * FROM tblGrid WHERE dateEntered between Now() - 30 and Now()

-->

note: dateEntered are the dates in my date field (mm-dd-yyyy)

Thanks a lot.

If you are using VB.NET, you can use DateTime.Add method. There's an exampe in the docs here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassaddtopic.asp

Thursday, March 22, 2012

Supress error/warning of winapi in class?

I have this error:
Warning 1 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated...
This because i have a call in a win32 dll:
Public Declare Ansi Function TheCall Lib "MyDll.DLL" Alias "TheCall" (ByVal
szKey As String) As Int32
Option Explict or Strict don't do anything here.
I'm looking for a solution hopefully placed in the class itself if possible.
The call is executed through the dimensioned class var.
'you are referencing a static method from an instance rather than its class.
use ClassName.MethodName (class referenece), not myObj.MethodName (instance
reference)
-- bruce (sqlwork.com)
"Edwin Knoppert" <news@.hellobasic.com> wrote in message
news:439eef25$0$2339$ba620dc5@.text.nova.planet.nl...
>I have this error:
> Warning 1 Access of shared member, constant member, enum member or nested
> type through an instance; qualifying expression will not be evaluated...
> This because i have a call in a win32 dll:
> Public Declare Ansi Function TheCall Lib "MyDll.DLL" Alias "TheCall"
> (ByVal szKey As String) As Int32
> Option Explict or Strict don't do anything here.
> I'm looking for a solution hopefully placed in the class itself if
> possible.
> The call is executed through the dimensioned class var.
> '
>
Hey, thanks, thought the declares where not public, brain-dead of course.
It says: PUBLIC :)
To bad i couldn't reuse my WITH statement with these calls.
I swapped it for the dimmed object but MS does not like that :)
Thanks,
"Bruce Barker" <brubar_nospamplease_@.safeco.com> schreef in bericht
news:eMrI3rAAGHA.1268@.TK2MSFTNGP11.phx.gbl...
> you are referencing a static method from an instance rather than its
> class. use ClassName.MethodName (class referenece), not myObj.MethodName
> (instance reference)
> -- bruce (sqlwork.com)
>
> "Edwin Knoppert" <news@.hellobasic.com> wrote in message
> news:439eef25$0$2339$ba620dc5@.text.nova.planet.nl...
>

Tuesday, March 13, 2012

Switch case (C#)

How can a use a expression like (percent_ < 25) into the switch case?
It's returning me a error.

switch (percent_) {case(percent_ < 25): img.ImageUrl ="~/img/BarraHorizGreen.gif";break;case(percent_ > 40): img.ImageUrl ="~/img/BarraHorizRed.gif";break;default: img.ImageUrl ="~/img/BarraHorizYellow.gif"; }

Sorry, C# does not support fall-through cases, each case must be exact. ref:http://msdn2.microsoft.com/EN-US/library/aa664749(VS.71).aspx

Work around is easy, use if...else statement.


in VB it would be possible like..

Select Case XCase 126 to 500' any number between 126 and 500Case 5, 9, 125' 5 or 9 or 125Case is > 800' any number greater than 800Case Else'End Select
but i think it would nt be possible in C#.. you can use Else..IF  Ladder..
hope it helps./.