I have a very interesting and frustrating problem. I use a method the get text from several fields and use them to check if an order has changed.
Here is my method:
[code]Function OrderGetFields() As String
dim s As String
s = s + OCustomer.Text
s = s + OClass.Text
s = s + OTemplate.Text
s = s + OShipTo.Text
s = s + ODate.DateValue.SQLDate
's = s + OSONO.Text
s = s + OTerms.Text
s = s + ODueDate.DateValue.SQLDate
s = s + ORep.Text
s = s + OPONO.Text
s = s + OOther.Text
's = s + OShipDate.DateValue.SQLDate
s = s + OShipVia.Text
s = s + OFOB.Text
s = s + cstr(OPrintLater.Value)
s = s + CStr(OEmailLater.Value)
s = s + OMsg.Text
s = s + OMemo.Text
's = s + OTax.Text
s = s + OTaxCode.Text
On my computer this works as expected, but my client (windows 7) keeps getting false warnings. Adding the .lowercase helped some.
I even added a msgbox to show differences. In the msg displayed the two strings being compared look identical. Also the string.len is the same. But still Order = OrderGetFields returns false.
Also note that I commented out the OTax.text (combobox) because it would return inconsistent results. ‘Tax 7.00%’ would sometimes be returned as ‘Tax 7.0\%’.
I should note that I just switched to Valentina SQLite Server, and the fields are being populated from the database.
“false warnings”… hard to help when you failed to provide information as to how the result of this function is used.
If you are comparing this result, to a result created by another function,
- be sure they do the exact same thing (EXACT)
- be aware of differences in string lengths
- be aware of zombies (non-printable characters)
- examine both strings in the debugger (hex) and eyeball that they are truly the same (because obviously SOMETHING is off)
- FYI… \% is an escape sequence , and you might see similar with quotes, ampersands, and other characters
- Also, if the comparison is being done in Xojo, then lowecase really won’t matter, as the standard string comparison is not case senstive.
I have a global variable Order as string. It contains the string from the most recently loaded order.
I tried adding a timer the runs slightly after the LoadOrder method, and gets the text from the fields. We’ll see if this works. My thinking was that until the method completes perhaps the controls.text is in an inconsitant state.
Here is a representation of what I’m doing (not actual working code)
sub LoadOrder(ID as String)
if WarnToSave then return
'load the data into the fields...
Order = OrderGetFields
Function WarnToSave() As Boolean
if Order <> OrderGetFields then
'warn the user ask to save etc...
return true 'or false depending on the user selection
I’m wondering if it could have anything to do with my recent switch to Valentina SQLite Server. Data format/encoding???