String found double expected, lotusscript - lotus-notes

In Lotusscript I have this:
Dim PurchaseValue As Double
PurchaseValue = CDbl (docOrder.InkoopKeerAantal(0))
On the form InkoopKeerAantal is a Number.
I get the error:
Type mismatch in method CoerStrToNum: STRING found, Double Expected.
If I do CInt then I get String found Short expected...
And PurchaseValue = docOrder.InkoopKeerAantal(0)
Also gives me the same error as above.

PurchaseValue = docOrder.getItemValue("InkoopKeerAantal")(0) might do it.

My reference was to a wrong document.. Thanks everyone and sorry of this mistake

Related

How to express a Double in Shape.SetFormula?

I am trying to input a Double value into a Shape.SetFormula command
for example the following is something which I recorded via the journaling function of NX:
moveObjectBuilder1.TransformMotion.Angle.SetFormula("12.5")
According to the microsoft website, the value inside the () can only be an Integer, and obviously, any value (no matter Integer or Double value) written in this form "xxx" can be executed.
As far as I understood, "" is a String, so I changed the code like the following :
Function value() As String
Return 25/2
End Function
Sub Main(ByVal As String)
.
.
.
moveObjectBuilder1.TransformMotion.Angle.SetFormula(value())
.
.
.
End Sub
However, there will be a syntax error if the code is written like this.
May I ask, how can I let the Shape.Formula() command read a Double value? Or how can I let the Function return a value which will be in this format "..."?
Thank you very much!
I have no experience with that application but, as far as I can tell, the parameter for that method is type String because it accepts a String containing a mathematical formula that will be parsed internally. In that case, something like this should work:
moveObjectBuilder1.TransformMotion.Angle.SetFormula("25 / 2")
and do exactly the same thing as this:
moveObjectBuilder1.TransformMotion.Angle.SetFormula("12.5")
If that's not working for you then please explain EXACTLY what happens when you do it.
I've managed to solve my own problem. It was actually quite stupid, I am just simply not an expert in programming. It only took me several more tries to get the solution to my problem.
moveObjectBuilder1.TransformMotion.Angle.SetFormula("Sqrt(2)")
This is the correct way to express "Rotate this object with the angle of square root of 2."
Okay now let's talk about the problem which I've encountered. What I want is, import a value via a function, and then process it. So, SetFormula only accepts String. Therefore I can do the following :
Function value() As Double
Return 25/2
End Function
Sub Main(ByVal arg() As String)
.
.
.
moveObjectBuilder1.TransformMotion.Angle.SetFormula(value().ToString)
.
.
.
End Sub

String.Split() method creates empty array spot

I am not a professional programmer, just FYI.
I am having trouble splitting a string. The resulting array has a length of 3, with the second spot (index 1) being completely empty.
I could manipulate the array to work the way I'd like, but I would rather understand why it is acting this way and code it properly from the beginning.
Dim defaultSetting() As String
Dim curSetting as String = "MENU_ITEM_ON_OPEN;;OPTIONAL_LEAVE"
defaultSetting = curSetting.Split(";;")
MsgBox(defaultSetting.Length) 'this is 3
MsgBox(defaultSetting(0)) 'this is as expected "MENU_ITEM_ON_OPEN"
MsgBox(defaultSetting(1)) 'this is empty and I do not know why
MsgBox(defaultSetting(2)) 'this is "OPTIONAL_LEAVE" and should be stored in defaultSetting(1)
Any help would be appreciated, thank you.
The problem here is that Option Strict is set to Off.
The overload of Split which is used expects a ParamArray of Char.
Because of this, the string ";;" is "silently" converted to a single char.
You can check this with following code:
Dim x As Char = ";;"
MsgBox(x)
You want to split by a string, which means you have to use another overload:
defaultSetting = curSetting.Split({";;"}, StringSplitOptions.None)
Thanks to a comment made by dbasnett I was able to find code that worked the way I was expecting, although I am not really sure why if anyone care to explain. But if not, this question has been answered, thanks.
defaultSetting = testString.Split(CType(";;", Char()), StringSplitOptions.RemoveEmptyEntries)

vb.net Unable to keep decimal places when converting string to single

I have been working on a vb.net project and have run into a problem. I have tried various implementations from Stackoverflow and MSDN but nothing is working. All I am trying to do is convert a string value to a single and keep the precision.
An example of the code would be something like this:
Dim Total As Single = 0
Dim s as String = "427.00"
Total += Single.Parse(s)
// Total = 427
// Expected : 427.00 <-- I need this
I have tried using cultureinfo.invariant,
I have tried using string.format,
I have tried using double instead of single,
I don't know what I am missing.
Any insight would be appreciated, and I can provide more code of what the application is trying to do if necessary.
In addition to #Alex B.'s comment, this is how you would achieve this. Total is a String but the program will bomb if either is not a Single type giving you some type safety.
Dim Total As String = "0"
Dim s as String = "427.00"
Total = (Single.Parse(Total) + Single.Parse(s)).ToString("0.00")

JUnit string comparison

I know how strings are compared and I read online that using:
assertEquals(String,String);
is safe... However I get following error:
junit.framework.AssertionFailedError: expected:<53> but was:<53>
In particular I do something like this:
assertEquals(totalRecipients.toString(), dataLineCount);
dataLineCount doesn't sound like a String to me - but I can't say for sure without looking at your code.
Assuming dataLineCount is an int you would not be calling assertEquals(String,String) but assertEquals(Object,Object) with a String and an Integer as arguments (because of autowrapping). And String and Integer don't compare equal...

Invalid Qualifier error in Visual Basic 6.0

In a Visual Basic 6.0 program, I have a string sTemp that I want to ensure does not contain a quotation mark. I have the line:
If sTemp.Contains("""") Then
But when I type the period after sTemp, I don't get anything from intellisense, and when I try to compile I get the following error:
Compile error:
Invalid qualifier
VB6 strings are not objects, so there are no methods on the string variable that you can call.
To test does the string contain quotes you need to use the InStr function i.e.
if InStr(sTemp, """") > 0 then ' string contains at least one double quote
Hope this helps
UPDATE This has nothing to do with the original question
William, I just thought of this, it is unrelated information that you may find useful.
There are many ways to shoot yourself in the foot with VB6.
Among the less obvious is the fact that
Dim myCollection as new Collection
will have side effects you could never imagine.
Never DIM something AS New CSomething
Dim your variable, then on a second line, assign it to a new object. Hope this helps.
Dim myCollection as Collection
Set myCollection = New Collection
Try if instr(sTemp, """") > 0 then

Resources