|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Nullable 2.0 Frameworksomething to Not exist, basically you can pass 'Nothing' to a method whose parameters as System.Nullable. Im looking at table adapters ; you know those clever little things which allow you to contrsuct methods for manipulating data use this. So a method might be declared someting like this. Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal myweek As System.Nullable(Of Integer)) End Sub My question is. How to I translate this into a practical method call for a value which may or may not exits. Lets say we have two text boxes. yearTextBox and weekTextBox. How to I assign an integer value or nothing depending on if the box is emtpy, because you cant assign nothing to an integer. I dont want multiple call lines to the one method, just one. -- Goofy -- Goofy Goofy wrote:
Show quoteHide quote > The 2.0 Framework has a new type called System.Nullable. This allows I think that an object of type Nullable(Of Integer) can hold either an> something to Not exist, basically you can pass 'Nothing' to a method whose > parameters as System.Nullable. > > Im looking at table adapters ; you know those clever little things which > allow you to contrsuct methods for manipulating data use this. So a method > might be declared someting like this. > > Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal > myweek As System.Nullable(Of Integer)) > > End Sub > > My question is. How to I translate this into a practical method call for a > value which may or may not exits. Lets say we have two text boxes. > yearTextBox and weekTextBox. > > How to I assign an integer value or nothing depending on if the box is > emtpy, because you cant assign nothing to an integer. I dont want multiple > call lines to the one method, just one. > > -- > Goofy > integer value, or Nothing. To access the value of it use th Value property. If you are worried about getting Nothing from it, use the HasValue property which will tell you if the Nullable object stores a value, or stores Nothing. Inside your myMethod, you could say: if myYear.HasValue then myYearTextBox.text = myYear.Value else myYearTextBox.text = "" end if Well, thats doesent quite work because the sql where clause is like this.
WHERE ((week_no=@week_no) or (@week_no is null)) AND ( (pyear=@pyear) or (@pyear is null) ) so the TableAdapterMethod needs to see either Nothing or a Value. So my question is how do I call this on one line. <lord.zol***@gmail.com> wrote in message Show quoteHide quote news:1166624070.741818.224190@a3g2000cwd.googlegroups.com... > > Goofy wrote: >> The 2.0 Framework has a new type called System.Nullable. This allows >> something to Not exist, basically you can pass 'Nothing' to a method >> whose >> parameters as System.Nullable. >> >> Im looking at table adapters ; you know those clever little things which >> allow you to contrsuct methods for manipulating data use this. So a >> method >> might be declared someting like this. >> >> Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal >> myweek As System.Nullable(Of Integer)) >> >> End Sub >> >> My question is. How to I translate this into a practical method call for >> a >> value which may or may not exits. Lets say we have two text boxes. >> yearTextBox and weekTextBox. >> >> How to I assign an integer value or nothing depending on if the box is >> emtpy, because you cant assign nothing to an integer. I dont want >> multiple >> call lines to the one method, just one. >> >> -- >> Goofy >> > > I think that an object of type Nullable(Of Integer) can hold either an > integer value, or Nothing. To access the value of it use th Value > property. If you are worried about getting Nothing from it, use the > HasValue property which will tell you if the Nullable object stores a > value, or stores Nothing. > > Inside your myMethod, you could say: > > if myYear.HasValue then > myYearTextBox.text = myYear.Value > else > myYearTextBox.text = "" > end if > Got it.
Dim year As System.Nullable(Of Single) Dim week As System.Nullable(Of Integer) Show quoteHide quote "Goofy" <m*@mine.com> wrote in message news:OieCFJEJHHA.4848@TK2MSFTNGP04.phx.gbl... > Well, thats doesent quite work because the sql where clause is like this. > > WHERE ((week_no=@week_no) or (@week_no is null)) AND ( (pyear=@pyear) > or (@pyear is null) ) > > > so the TableAdapterMethod needs to see either Nothing or a Value. So my > question is how do I call this on one line. > > > <lord.zol***@gmail.com> wrote in message > news:1166624070.741818.224190@a3g2000cwd.googlegroups.com... >> >> Goofy wrote: >>> The 2.0 Framework has a new type called System.Nullable. This allows >>> something to Not exist, basically you can pass 'Nothing' to a method >>> whose >>> parameters as System.Nullable. >>> >>> Im looking at table adapters ; you know those clever little things which >>> allow you to contrsuct methods for manipulating data use this. So a >>> method >>> might be declared someting like this. >>> >>> Private Sub myMethod(ByVal myYear As System.Nullable(Of Integer), ByVal >>> myweek As System.Nullable(Of Integer)) >>> >>> End Sub >>> >>> My question is. How to I translate this into a practical method call for >>> a >>> value which may or may not exits. Lets say we have two text boxes. >>> yearTextBox and weekTextBox. >>> >>> How to I assign an integer value or nothing depending on if the box is >>> emtpy, because you cant assign nothing to an integer. I dont want >>> multiple >>> call lines to the one method, just one. >>> >>> -- >>> Goofy >>> >> >> I think that an object of type Nullable(Of Integer) can hold either an >> integer value, or Nothing. To access the value of it use th Value >> property. If you are worried about getting Nothing from it, use the >> HasValue property which will tell you if the Nullable object stores a >> value, or stores Nothing. >> >> Inside your myMethod, you could say: >> >> if myYear.HasValue then >> myYearTextBox.text = myYear.Value >> else >> myYearTextBox.text = "" >> end if >> > >
VB.Net advice needed
Windows History Deletion MDI Forms Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register VB and CCTV Exporting data to excel not working..... Threading Mailmerge date problem Running installed application asks for MSI 2-3 words in field name |
|||||||||||||||||||||||