|
BobInNJ wrote: ByRef mat(,))
I don't know the syntax, but you're clearly not specifying here what sort of array you're sending, and the match in variable names is irrelevant. I expect that means it's trying to take Object by default, and it's refusing to box it for you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
BobInNJ wrote:
The default type for mat , since you didn't specify it, is Object. Your code, as written, is actually:
Sub printMatrix(ByRef mat(,) As object)
By the way, the ByRef is redundent in this case since all reference type as always bassed by, well, reference.
Your code should read:
Sub printMatric(ByRef mat(,) As Double)
|
|
|
|
|
Dave,
Thanks for the response. You solved my problem.
Bob
|
|
|
|
|
Hello every body:
How I can make a blinking Label? I know I am unclear but I don't know how I can ask! Suppose there is a label that the text of it, is a red star, like this :
' * '
I want star like a light can be on and off, on and off, on and off…
I hope, my question is understandable and clear!
|
|
|
|
|
A way that I can think of doing this is to have a timer and handle its tick event. In that event, just remove and add "*" to the label text.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
use a System.Windows.Forms.Timer, and in its Tick handler modify the Label properties; either Visible, or ForeColor or Text.
|
|
|
|
|
I have a function as follows:
Function XYZ As Boolean
End Function
That's right, there is no code in the function. Does it return True by default?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
what have you tried so far?
what says the documentation?
do you use "Options Strict On"? I know I would.
|
|
|
|
|
I don't "try" VB. I'm just trying to understand their code.
I think strict is on.
I just need an answer to my question - yes or no.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I don't have the official answer. Most likely this one[^] is pretty close:
"Because VB.NET has defined a 'hidden' variable that is returned by the
function, this variable is the same name as the function. If you do not use
the Return statement, this variable is returned automatically. If you do not
set the variable the default value is used"
and I would expect the hidden variable to be defaulted to nada, all bits zero, just like
class data members, hence False for booleans.
It is bound to be a VBx relic.
|
|
|
|
|
A quirky little language, but the default value returned is the default value of the type the function is supposed to return. In your case, False. In the case of numeric types, an appropriate value of 0. For references types, Nothing (null in C#).
|
|
|
|
|
that's what I call nada. However I wasn't able to quickly find it anywhere in official documents...
|
|
|
|
|
Dave Kreskowiak wrote: For references types, Nothing (null in C#).
The C# equivalent code won't compile. In C# there is no default and you must specify a return or you get a compilation error. That's one of the reasons I prefer C# to VB, because it's a bit "tighter" on some things. (Not meant to start a language war: I like VB too, and I like Java and Python. I am multi-denominational in my coding.)
|
|
|
|
|
David Skelly wrote: The C# equivalent code won't compile. In C# there is no default and you must specify a return or you get a compilation error.
I didn't say it would. John is a C# guy and "Nothing" may seem a little strange to him, so I gave him the C# equiv to Nothing, which is null.
|
|
|
|
|
Why not run the code and check yourself? You can also create one sample kind of solution and test this.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Basically because one should, as much as possible, base coding decisions on documentation, not observation. If behavior isn't documented, it has a higher probability of getting changed over time (or it may even not be constant at all, and the observation might miss that).
|
|
|
|
|
Luc Pattyn wrote: Basically because one should, as much as possible, base coding decisions on documentation, not observation
Man am I in the poop, scenario, you get a new tool to play with, the last one was spreadsheetgear, do you seriously read the doco or go down and kick the tyres.
Me, if the tyre goes flat I then turn to the doco to find out why. If I see weird behavior I will resort to the doco but only after absorbing the examples first.
I vote he should have tried the function accepted the false default and moved on.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: if the tyre goes flat I then turn to the doco to find out why
Wow, if my tyre goes flat I go and put more air in it. If it keeps going flat, i get it checked at the tyre centre.
|
|
|
|
|
I don't base my developments on an "it seems to work" approach:
When given a new compiler for a new language, I'll play with it first for an hour or so, then spend up to two days reading at least one book about it, then get productive right away. And when given an existing code base in that new language, I will not change a thing to it before I feel comfortable with the language, so that IMO is why John asked the question he asked.
|
|
|
|
|
When you explicitly return no value before the function call ends, the default value for the return type is returned. In case of Boolean, it is False.
On a logical side, True is expected to signal a success, when you have not written any code at all, how do you expect it to return True by default.
|
|
|
|
|
It returns False by default.
|
|
|
|
|
Puzzled by this one...
Previously I had a Module that worked perfectly.
It now doesn't.
It is crashing out on this bit
ActiveWorkbook.SendMail _<br />
Recipients:="someone@somewhere.co.uk", _<br />
Subject:="Bank Balances "
The only change is that previously it was held on my hard drive, but now it is on a shared drive (Q:\)
Why would changing the location it is lifted from and saved to stop this line from working?
It is the ActiveWorkbook that I wish to send, not the saved copy on the HDD.
Excel 2007, and it worked until this change.
Is there a work around?
How would I send a file from a HDD as an extension in an email?
------------------------------------
In science, 'fact' can only mean 'confirmed to such a degree that it would be perverse to withhold provisional assent.' I suppose that apples might start to rise tomorrow, but the possibility does not merit equal time in physics classrooms. Stephen J Gould
|
|
|
|
|
Probably because of security for running macros through a network shared directory, you might want to make a local copy on your hard disk, I do not know of any workarounds for this and am pretty confident this is a security issue.
|
|
|
|
|
EliottA wrote: you might want to make a local copy on your hard disk, I do not know of any workarounds for this and am pretty confident this is a security issue.
Done!
And Works.
Did it by creating a temp file on my HDD, sending that, then deleting it.
(Actually I saved to Q: then saved to D:, then closed and reopened from D: and sent, then closed and deleted. Bit of a Kludge, but it works)
Thanks V Much.
------------------------------------
In science, 'fact' can only mean 'confirmed to such a degree that it would be perverse to withhold provisional assent.' I suppose that apples might start to rise tomorrow, but the possibility does not merit equal time in physics classrooms. Stephen J Gould
|
|
|
|
|
I am trying to get the index of an object in an Arraylist. Please see my example. When run I get -1 for the values of Indexof.
I am sure this is a rookie error but any help would be appreciated.
Cheers
Public Class Plateobj
Public Name As String
Public Order As Integer
End Class
Private Sub Go()
Dim Plate As New Plateobj
Dim List As New ArrayList
'Populate arraylist
Plate.Name = "Geoff"
Plate.Order = 3
List.Add(Plate)
Plate = New Plateobj
Plate.Name = "Dan"
Plate.Order = 2
List.Add(Plate)
Plate.Name = "Paul"
Plate.Order = 1
List.Add(Plate)
'Locate the index of each of the following
MessageBox.Show(List.IndexOf(Plate), "Paul")
Plate = New Plateobj
Plate.Name = "Dan"
Plate.Order = 1
MessageBox.Show(List.IndexOf(Plate), "Dan")
Plate = New Plateobj
Plate.Name = "Geoff"
Plate.Order = 3
MessageBox.Show(List.IndexOf(Plate), "Geoff")
End Sub
modified on Friday, November 27, 2009 6:36 AM
|
|
|
|