Home All Groups Group Topic Archive Search About

Option Strict disallows late binding, need to update code

Author
6 Apr 2005 5:31 PM
CodeMonkey
Hi All
the following code generates an error with option strict on - Option
strict disallows late binding. Can someone please help with what needs
to be changed:

Dim sweep, totalsweep As Integer
Dim slices As Array = Split("26, 40, 34",",")
Dim colors() As Color = { _
Color.Blue, Color.LimeGreen, _
Color.Purple}
Dim brush As System.Drawing.SolidBrush
Dim g As System.Drawing.Graphics
g = Me.CreateGraphics

For i As Integer = 0 To UBound(slices)

brush = New System.Drawing.SolidBrush(colors(i))
sweep = 360 * (CLng(slices(i)) / 100) '<----PROBLEM HERE
If totalsweep + sweep > 360 Then _
sweep = 360 - totalsweep
g.FillPie(brush, New Rectangle(0, 0, 80, 80), _
totalsweep, sweep)
totalsweep += sweep
Next

Thanks
CodeMonkey.

Author
6 Apr 2005 5:57 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"CodeMonkey" <agaskel***@yahoo.com> schrieb:
> the following code generates an error with option strict on - Option
> strict disallows late binding. Can someone please help with what needs
> to be changed:
>
> Dim sweep, totalsweep As Integer
> Dim slices As Array = Split("26, 40, 34",",")
> Dim colors() As Color = { _
> Color.Blue, Color.LimeGreen, _
> Color.Purple}
> Dim brush As System.Drawing.SolidBrush
> Dim g As System.Drawing.Graphics
> g = Me.CreateGraphics
>
> For i As Integer = 0 To UBound(slices)
>
> brush = New System.Drawing.SolidBrush(colors(i))
> sweep = 360 * (CLng(slices(i)) / 100) '<----PROBLEM HERE

Replace the line above with this:

\\\
sweep = CInt(360 * (CLng(slices.GetValue(i)) / 100))
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
6 Apr 2005 6:11 PM
AMercer
You may also want to change
   Dim slices As Array = Split("26, 40, 34",",")
to
   Dim slices() As String = Split("26, 40, 34", ",")
because it appears that your intention is that slices is an array of strings.
Author
6 Apr 2005 6:18 PM
Herfried K. Wagner [MVP]
"AMercer" <AMer***@discussions.microsoft.com> schrieb:
> You may also want to change
>   Dim slices As Array = Split("26, 40, 34",",")
> to
>   Dim slices() As String = Split("26, 40, 34", ",")
> because it appears that your intention is that slices is an array of
> strings.

Full ACK.  Thanks for adding that... :-).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
6 Apr 2005 6:17 PM
Samuel R. Neff
Change this line:

Dim slices As Array = Split("26, 40, 34", ",")

To

Dim slices As String() = Split("26, 40, 34", ",")

HTH,

Sam


Show quoteHide quote
On 6 Apr 2005 10:31:07 -0700, "CodeMonkey" <agaskel***@yahoo.com>
wrote:

>Hi All
>the following code generates an error with option strict on - Option
>strict disallows late binding. Can someone please help with what needs
>to be changed:
>
>Dim sweep, totalsweep As Integer
>Dim slices As Array = Split("26, 40, 34",",")
>Dim colors() As Color = { _
>Color.Blue, Color.LimeGreen, _
>Color.Purple}
>Dim brush As System.Drawing.SolidBrush
>Dim g As System.Drawing.Graphics
>g = Me.CreateGraphics
>
>For i As Integer = 0 To UBound(slices)
>
>brush = New System.Drawing.SolidBrush(colors(i))
>sweep = 360 * (CLng(slices(i)) / 100) '<----PROBLEM HERE
>If totalsweep + sweep > 360 Then _
>sweep = 360 - totalsweep
>g.FillPie(brush, New Rectangle(0, 0, 80, 80), _
>totalsweep, sweep)
>totalsweep += sweep
>Next
>
>Thanks
>CodeMonkey.

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position. 
Seaking mid to senior level developer.  For
information or to apply e-mail resume to
sam_blinex_com.
Author
6 Apr 2005 6:31 PM
Marcie Jones
Or even:

>Dim slices As Array = Split("26, 40, 34", ",")
>Dim slices As String() = Split("26, 40, 34", ",")

to
Dim slices As String() = {"26", "40", "34"}

Marcie

On Wed, 06 Apr 2005 14:17:11 -0400, Samuel R. Neff
<blinex@newsgroup.nospam> wrote:

Show quoteHide quote
>
>Change this line:
>
>Dim slices As Array = Split("26, 40, 34", ",")
>
>To
>
>Dim slices As String() = Split("26, 40, 34", ",")
>
>HTH,
>
>Sam
>
>
>On 6 Apr 2005 10:31:07 -0700, "CodeMonkey" <agaskel***@yahoo.com>
>wrote:
>
>>Hi All
>>the following code generates an error with option strict on - Option
>>strict disallows late binding. Can someone please help with what needs
>>to be changed:
>>
>>Dim sweep, totalsweep As Integer
>>Dim slices As Array = Split("26, 40, 34",",")
>>Dim colors() As Color = { _
>>Color.Blue, Color.LimeGreen, _
>>Color.Purple}
>>Dim brush As System.Drawing.SolidBrush
>>Dim g As System.Drawing.Graphics
>>g = Me.CreateGraphics
>>
>>For i As Integer = 0 To UBound(slices)
>>
>>brush = New System.Drawing.SolidBrush(colors(i))
>>sweep = 360 * (CLng(slices(i)) / 100) '<----PROBLEM HERE
>>If totalsweep + sweep > 360 Then _
>>sweep = 360 - totalsweep
>>g.FillPie(brush, New Rectangle(0, 0, 80, 80), _
>>totalsweep, sweep)
>>totalsweep += sweep
>>Next
>>
>>Thanks
>>CodeMonkey.
>
>B-Line is now hiring one Washington D.C. area VB.NET
>developer for WinForms + WebServices position. 
>Seaking mid to senior level developer.  For
>information or to apply e-mail resume to
>sam_blinex_com.
Author
6 Apr 2005 7:46 PM
Samuel R. Neff
Or

Dim slices As Integer() = {26, 40, 34}

Then no need for conversion later. 

Sam


On Wed, 06 Apr 2005 14:31:28 -0400, Marcie Jones
<marciejo***@yahoo.com> wrote:

Show quoteHide quote
>Or even:
>
>>Dim slices As Array = Split("26, 40, 34", ",")
>>Dim slices As String() = Split("26, 40, 34", ",")
>
>to
>Dim slices As String() = {"26", "40", "34"}
>
>Marcie
>
>On Wed, 06 Apr 2005 14:17:11 -0400, Samuel R. Neff
><blinex@newsgroup.nospam> wrote:
>
>>
>>Change this line:
>>
>>Dim slices As Array = Split("26, 40, 34", ",")
>>
>>To
>>
>>Dim slices As String() = Split("26, 40, 34", ",")
>>
>>HTH,
>>
>>Sam
>>
B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position. 
Seaking mid to senior level developer.  For
information or to apply e-mail resume to
sam_blinex_com.
Author
6 Apr 2005 8:21 PM
CodeMonkey
All,
thanks for your extremely prompt and accurate help.

Regards
CodeMonkey.

Samuel R. Neff wrote:
Show quoteHide quote
> Or
>
> Dim slices As Integer() = {26, 40, 34}
>
> Then no need for conversion later.
>
> Sam
>
>
> On Wed, 06 Apr 2005 14:31:28 -0400, Marcie Jones
> <marciejo***@yahoo.com> wrote:
>
> >Or even:
> >
> >>Dim slices As Array = Split("26, 40, 34", ",")
> >>Dim slices As String() = Split("26, 40, 34", ",")
> >
> >to
> >Dim slices As String() = {"26", "40", "34"}
> >
> >Marcie
> >
> >On Wed, 06 Apr 2005 14:17:11 -0400, Samuel R. Neff
> ><blinex@newsgroup.nospam> wrote:
> >
> >>
> >>Change this line:
> >>
> >>Dim slices As Array = Split("26, 40, 34", ",")
> >>
> >>To
> >>
> >>Dim slices As String() = Split("26, 40, 34", ",")
> >>
> >>HTH,
> >>
> >>Sam
> >>
> B-Line is now hiring one Washington D.C. area VB.NET
> developer for WinForms + WebServices position.
> Seaking mid to senior level developer.  For
> information or to apply e-mail resume to
> sam_blinex_com.