473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Option Strict disallows late binding, need to update code

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.

Nov 21 '05 #1
7 4856
"CodeMonkey" <ag********@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/>
Nov 21 '05 #2
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.

Nov 21 '05 #3

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" <ag********@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.
Nov 21 '05 #4
"AMercer" <AM*****@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/>

Nov 21 '05 #5
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
<bl****@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
On 6 Apr 2005 10:31:07 -0700, "CodeMonkey" <ag********@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.


Nov 21 '05 #6

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
<ma*********@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
<bl****@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.
Nov 21 '05 #7
All,
thanks for your extremely prompt and accurate help.

Regards
CodeMonkey.

Samuel R. Neff wrote:
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
<ma*********@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
<bl****@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.


Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I...
12
by: Simon Harris | last post by:
Hi All, I've been advised to use option strict. I've tried to read up on this, all i can find is that it... "disallows implicit narrowing conversions" This kinda makes sense - Means I have...
12
by: Doug Hill | last post by:
Please, Microsoft, update Option Explicit Option Strict barks at late binding. We love late binding. So Option Strict flags too many things. Option Explicit is misleading. It allows Dim...
11
by: Dieter Schwerdtfeger via DotNetMonster.com | last post by:
I have this function where i search through my database for items that were made on a specific date. The line "CType(dvClubs.Item(teller).Item(veld).ToShortDateString" gives me the error : option...
3
by: Starbuck | last post by:
Hi The following generates an error when Option Strict is On Can anytell tell me how to get round this please. Private Sub optWithTone_CheckedChanged(ByVal eventSender As System.Object, ByVal...
4
by: Heinz | last post by:
Hi all, I use VB.net 2003 and want to export data to Excel. Target PCs still have Office 2000 so I could not use Microsofts PIAs. Instead I use the included Excel 10 COM DLL from Microsoft....
7
by: Owen Mortensen | last post by:
(This code was working in asp.net 1.1 VS2003. After upgrade to VS2005, chokes): in the aspx file: <ItemTemplate> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"...
1
by: Adotek | last post by:
Hi All, I've just converted a solution from .Net v1.1 to v2.0, by allowing Visual Studio 2005 to do the conversion. Since doing so, I am getting a compilation error as follows: "Option...
7
by: Lynn | last post by:
Hello, I have a website that is working fine. I have just turned on "option strict" and am getting an error with the parts of my code. I have fixed everything but this section, which has me...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.