Thursday, March 22, 2012
Supress error/warning of winapi in class?
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 with enum
i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
----
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
------
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
break;
case ....
}
----------
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> ----
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> ------
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> break;
> case ....
> }
> ----------
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > i am getting "a constant value is required" error when i use the enum
> > value
> > in case statement/
> > Any ideas?
> > sample code:
> > myconfig.cs
> > ----
> > public enum WebHostingTypes
> > {
> > [Description("BASIC")] Basic,
> > [Description("PLUS")] Plus,
> > [Description("PREM")] Premium
> > }
> > product.cs
> > ------
> > switch(WebHostingType)
> > {
> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> > break;
> > case ....
> > }
> > ----------
*********************** 2ND EXAMPLE
> > Even if i tried using a something like
> > public enum Volume
> > {
> > Low,
> > Medium,
> > High
> > }
> > string myVolume = "Medium";
> > switch(myVolume)
> > {
> > case myconfig.Volume.Medium:
> > break;
> > case ....
> > }
> > - Gane
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>> Enumerated values are numbers. If you treat them as such you will have no
>> problems with them.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> What You Seek Is What You Get.
>>
>> "gane kol" <ganekol@.softca.com> wrote in message
>> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
>> > Hi
>>> > i am getting "a constant value is required" error when i use the enum
>> > value
>> > in case statement/
>> > Any ideas?
>>> > sample code:
>>> > myconfig.cs
>> > ----
>> > public enum WebHostingTypes
>> > {
>>> > [Description("BASIC")] Basic,
>>> > [Description("PLUS")] Plus,
>>> > [Description("PREM")] Premium
>>> > }
>>> > product.cs
>> > ------
>>> > switch(WebHostingType)
>>> > {
>>> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
>> > break;
>>> > case ....
>>> > }
>>> > ----------
>>
>
> *********************** 2ND EXAMPLE
>> > Even if i tried using a something like
>>> > public enum Volume
>>> > {
>>> > Low,
>>> > Medium,
>>> > High
>>> > }
>>> > string myVolume = "Medium";
>>> > switch(myVolume)
>>> > {
>>> > case myconfig.Volume.Medium:
>> > break;
>>> > case ....
>>> > }
>>> > - Gane
>>>>
>>
switch case with enum
i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
--
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
--
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
break;
case ....
}
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S
"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> --
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> --
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
> break;
> case ....
> }
> --
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
>
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S
> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
*********************** 2ND EXAMPLE
>
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S
"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>
>
> *********************** 2ND EXAMPLE
>
>