I know I am being incredibly dunderheaded about this consider the following:
STRICT ON
Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}}
Private Sub T1(ByVal a As Array)
Dim i, j As Integer
For i = 0 To 2
For j = 0 To 2
a(i, j) = 2 * a(i, j) Underlined as latebinding error
Next
Next
End Sub
My understanding of late binding is that it occurs when there is ambiguity
in the array as declared and there is subsequent specificity in an assignment
of that array. It seems to me that declaring this array as a two dimensional
array of double is pretty specific.
Evidently VB considers the array to be of sype system array in spite of its
having been declared as above. I have philosophically arrived at a place
where I accept this. From a utilitarian standpoint, I must now deal with it.
One idea, proposed in this forum, is to use the CType function, but alas my
interpretaion produces an error:
Private Sub T2(ByVal a As Array)
Dim i, j As Integer
Dim localC(,) As Double = CType(a, Double) Error*
For i = 0 To 2
For j = 0 To 2
localC(i, j) = 2 * localC(i, j)
Next
Next
End Sub
*system array cannot be converted to double
Strict off is not an option. Array.copy works, but is it the best way?
--
mark 5 1764
Mark,
The convert functions in VBNet are so powerfull so why not use them.
a(i,j) = CDbl(2 * a(i,j))
I hope this helps?
Cor It seems to me that declaring this array as a two dimensional array of double is pretty specific.
The instance declaration "a(,) as double" is shadowed by the argument
declaration "a as array".
Therefore in the code "a" is just system.array and not a two
dimensional array of doubles.
Change the argument to be
Sub T1(a as double(,))
or don't pass it at all (it's already an instance variable).
OR
use the a.SetValue() and a.GetValue() methods to manipulate the values
in the array.
HTH,
Sam
Public Class ArrayOfDouble2
Public Shared Sub Test()
Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}}
Test2(a)
For i As Integer = 0 To 2
For j As Integer = 0 To 1
Console.WriteLi ne("({0}, {1}) -> {2}", i, j, a(i, j))
Next
Next
Console.ReadLin e()
End Sub
Public Shared Sub Test2(ByVal a As Array)
For i As Integer = 0 To 2
For j As Integer = 0 To 1
a.SetValue(CTyp e(a.GetValue(i, j), Double) * 2, i, j)
Next
Next
End Sub
End Class
On Tue, 1 Feb 2005 07:57:08 -0800, "mark"
<ma**@discussio ns.microsoft.co m> wrote:
I know I am being incredibly dunderheaded about this consider the following: STRICT ON Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}} Private Sub T1(ByVal a As Array) Dim i, j As Integer For i = 0 To 2 For j = 0 To 2 a(i, j) = 2 * a(i, j) Underlined as latebinding error Next Next End Sub My understanding of late binding is that it occurs when there is ambiguity in the array as declared and there is subsequent specificity in an assignment of that array. It seems to me that declaring this array as a two dimensional array of double is pretty specific.
Evidently VB considers the array to be of sype system array in spite of its having been declared as above. I have philosophically arrived at a place where I accept this. From a utilitarian standpoint, I must now deal with it. One idea, proposed in this forum, is to use the CType function, but alas my interpretaio n produces an error: Private Sub T2(ByVal a As Array) Dim i, j As Integer Dim localC(,) As Double = CType(a, Double) Error* For i = 0 To 2 For j = 0 To 2 localC(i, j) = 2 * localC(i, j) Next Next End Sub *system array cannot be converted to double
Strict off is not an option. Array.copy works, but is it the best way?
Mark, Private Sub T1(ByVal a As Array)
You defined the parameter to be the base type of all arrays rather then the
actual array.
Rarely do you want to pass parameters as Array, just as rarely do you want
to pass parameters as Object.
Try: Private Sub T1(ByVal a As Double(,)) Dim i, j As Integer For i = 0 To 2 For j = 0 To 2 a(i, j) = 2 * a(i, j) Underlined as latebinding error Next Next End Sub
If you want to cast the Array parameter try either:
Dim localC(,) As Double = CType(a, Double(,)) Dim localC(,) As Double = DirectCast(a, Double(,))
CType does both Convert & Cast, where as DirectCast only does Cast. To avoid
potential unexpected conversions I use DirectCast when I only want to cast.
Remember that both of the following are synonymous:
Dim a(,) As Double
Dim a As Double(,)
They both define a 2 dimensional array of Double. The second syntax is
needed when you need to define the specific array type as a parameter or
return type.
Hope this helps
Jay
"mark" <ma**@discussio ns.microsoft.co m> wrote in message
news:E9******** *************** ***********@mic rosoft.com...I know I am being incredibly dunderheaded about this consider the following: STRICT ON Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}} Private Sub T1(ByVal a As Array) Dim i, j As Integer For i = 0 To 2 For j = 0 To 2 a(i, j) = 2 * a(i, j) Underlined as latebinding error Next Next End Sub My understanding of late binding is that it occurs when there is ambiguity in the array as declared and there is subsequent specificity in an assignment of that array. It seems to me that declaring this array as a two dimensional array of double is pretty specific.
Evidently VB considers the array to be of sype system array in spite of its having been declared as above. I have philosophically arrived at a place where I accept this. From a utilitarian standpoint, I must now deal with it. One idea, proposed in this forum, is to use the CType function, but alas my interpretaion produces an error: Private Sub T2(ByVal a As Array) Dim i, j As Integer Dim localC(,) As Double = CType(a, Double) Error* For i = 0 To 2 For j = 0 To 2 localC(i, j) = 2 * localC(i, j) Next Next End Sub *system array cannot be converted to double
Strict off is not an option. Array.copy works, but is it the best way? -- mark
"mark" <ma**@discussio ns.microsoft.co m> schrieb: I know I am being incredibly dunderheaded about this consider the following: STRICT ON Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}} Private Sub T1(ByVal a As Array) Dim i, j As Integer For i = 0 To 2 For j = 0 To 2 a(i, j) = 2 * a(i, j) Underlined as latebinding error Next Next End Sub My understanding of late binding is that it occurs when there is ambiguity in the array as declared and there is subsequent specificity in an assignment of that array. It seems to me that declaring this array as a two dimensional array of double is pretty specific.
'a' is of type 'Array', not of type "two-dimensional array of doubles"
('Double(, )'). Either change the datatype of the 'a' parameter to
'Double(, )' or cast the array passed to 'T1':
\\\
Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}}
Private Sub T1(ByVal a As Array)
Dim B(,) As Double = DirectCast(a, Double(,))
Dim i, j As Integer
For i = 0 To 2
For j = 0 To 2
B(i, j) = 2.0 * B(i, j)
Next
Next
End Sub
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kenneth |
last post by:
Should I have it ON or OFF
//Kenneth
|
by: Rich |
last post by:
Hello,
If I leave Option Strict Off I can use the following
syntax to read data from a Lotus Notes application (a
NotesViewEntry object represents a row of data from a
Lotus Notes View - like a record in a sql Server view)
....
Dim entry As Domino.NotesViewEntry
Dim obj As Object
str1 = entry.ColumnValues(0)
|
by: Shannon Richards |
last post by:
Hello: I have a problem using ByRef arguments with Option Strict ON. I have
built a generic sub procedure "ChangeValue()" to change the value of an
argument if the new value is not the same as the original value...To
accommodate all variable types I made the arguments in ChangeValue() of type
object...I then check the typecode and do the correct comparison etc...
With Option Strict ON I have to cast the arguments to the generic object...
|
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 eventArgs As System.EventArgs) Handles optWithTone.CheckedChanged
If eventSender.Checked Then
pAlarmOption = NokiaCLCalendar.CalendarAlarmType.CALENDAR_ALARM_WITH_TONE
|
by: CodeMonkey |
last post by:
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}
| |
by: Brett |
last post by:
I find there is more casting required in C# than VB.NET. If Option
Strict/Explicit is turned on, will this basically create the same
environment as C# - uppercase, more casting required, must build event
handlers?
Thanks,
Brett
|
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. Everything works fine.
Now I want to sign my application with a strong name. Therefore I also
need to sign all DLLs. So I searched through the web and found
information that I need to use tlbimp, and the source file is
'xl5en32.olb'. Now this also...
|
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 Strict On disallows late binding."
This references line 1, which is my page directive:
|
by: Rob |
last post by:
I have employed a "Singleton mode" of programming for this project.
I have a class that exposes some properties of the class "Sample" to other
forms....
If I set Option Strict On, I get many "Option Strict On disallows late
binding" errors (see below)
How might I fix this ?
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |