How can I disable automatic string detection in VS2015? - vb.net

I'm using VB.NET, and my code contains a lot of strings that very often have double quotes inside of them. My problem is that as I'm fixing the string to escape double quotes (replacing every '"' with '""' inside of the string) it messes with the proceeding code, temporarily assuming everything is a string (since the double quotes don't match up) and completely messing up the formatting of other strings. It assumes that the start of a following string is the end of the current string which causes the actual string to be interpreted and formatted as code, which I have to go back and fix (since it adds spaces and other formatting characters that shouldn't actually be there).
Is there any way to disable this behavior? I didn't have the same problem in VS2013. I've been looking under Tools > Options > Text Editor > Basic, but I couldn't find anything relevant.
Additional Information: I can just modify the strings in a separate text document to escape all of the double-quotes (which is what I've resorted to for now), but in VS2013 I could easily just copy/paste the strings directly into my code without it messing up proceeding strings by temporarily interpreting them as code due to the uneven count of double-quotes.
This behavior is especially problematic when manually adding double-quotes within strings, because if you don't escape them quickly enough (or make a brief typo when doing so), you get the same issue.
You might notice that for other languages, such as C++, writing a string on one line (even with an uneven number of double-quotes) does not affect proceeding lines. Having this same behavior for VB would be great, assuming that there's some setting to enable it.

Yes its an inconvenience.
What I usually do is put some non-used character (e.g. some unused symbol on keyboard, or Alt+{some number}) instead of double quotes. When I'm done building my string whatever way I want, I just finalize it with either bringing up the Find and Replace box and replace that character with two double-quotes. Or just put a REPLACE statement immediately following it, replacing that character with Chr(34).

Instead use Chr(34), or if you end up repeating strings at all, store them as a resource.

Related

How to change VBA array decimal separator?

I would like to change VBA array decimal separator to dot. I see it as comma. I tried: Application.DecimalSeparator="."
But when I get the value as MyString = matrix(2, 1), the decimal separator in VBA arrays maliciously persists as comma. I am not able to get rid of the pest.
Is there a way to detect which system separator for VBA arrays is used?
VBA uses quite a few bits drawn from various parts of the platform to work out which decimal and thousands separator to use. Application.DecimalSeparator changes a few instances (mostly on the workbook); you can tweak others at the OS level, but even then though you get to a couple of cases where you can't change the settings.
Your best bet is to write a simple function to check which separator your platform uses based on a trial conversion of say 1.2 to a string and see what the second character ends up being. Crude but strangely beautiful.
Armed with that you can force an interchange of . and , as appropriate. Naturally then though you will have to manage all string to number parsing yourself, with some care.
Personally though I think this is epitomises an unnecessary fight with your system settings. Therefore I would leave everything as it is; grin and bear it in other words.
You have to change it in system settings, Excel takes this kind of settings from system.
I have end up with this function which does exactly what I want. Thank you all for answers, comments and hints.
Function GetVBAdecimalSep()
Dim a(0) As Variant
a(0) = 1 / 2
GetVBAdecimalSep = Mid(a(0), 2, 1)
End Function

Char & behaviour on controls

Currerently I face strange behaviour on my controls when text is present either on advlistbox items or buttonx and probably rest as well. This happens when i use & charackter within string. For instance when i use double && it shows single one. Another example when i put e.g &&&something then it shows &something with s - underscored. Is there anyone whom knows what is going on and how can i avoid that situation?
A double ampersand is used to escape the default behavior of an ampersand relative to controls. When an ampersand precedes control text it underlines the following character, usually to denote that controls hotkey. In the case of your triple ampersand situation you are using the right most ampersand as the underline and the remaining 2 as an escape so that a literal ampersand is displayed in your controls text.
If your goal is to literally display 2 ampersands then you must supply your control text with a total of 4 consecutive ampersands. (&&&&)

How do I keep the apostrophes when importing csv to sqlite

I am using an SQL database in an android app and have encountered a problem with apostrophes.
My database is a quotes database which I have in MS Excel 2007, then saved in .csv format. I then imported this into the sql table I have for the app. However the quotes with an apostrophe are not displaying correctly in the database (and therefore the app). Each apostrophe is replaced with a character that is invisible. I know it is there because of the character count and the fact that in the word "aren't" for example which looks like "arent" it take 3 clicks of the right arrow to get from the left side of the n to the right side of the t. If I manually add an apostrophe to the sql table it converts back to this invisible character when the database is saved. In the android app this invisible character shows up as a hollow rectangle.
I am sure the issue does not lie in my app's displaying of the quote because I have passed in a String to the same code and it displays apostrophes perfectly fine.
Is there a way to fix this issue, possibly by changing the character set or something like that? or does SQL not support apostrophes?
Since a single quote and apostrophe are the same character you have to do something in sql to tell the database when to treat it as part of a string or when to use it to surround a string. In every RDBMS of which I am aware, if you want the character to be part of a string, you "quote the quote", ie you change ' to '' when talking to your database.
That seems to be only part of your problem. The other part is that your android app displays this character as a rectangle instead or an apostrophe. That's got nothing to do with sql. That is a function of the android application.
I found an alternative solution to the problem.
At runtime of the app I'm replacing the invisible character with an apostrophe and the final string is then how the quote should look.
String quote = (get the quote from the SQL table)
char[] tempQuoteCharArr = new char[quote.length()];
tempQuoteCharArr = quote.toCharArray();
for(int i = 0; i < quote.length(); i++){
if(tempQuoteCharArr[i] == ''){
tempQuoteCharArr[i] = '\'';
}
}
quote = String.valueOf(tempQuoteCharArr);
The invisible character is between the single quotes in the if statement.

When I paste a string into Xcode I always get an error and have to re-type it

This happens every time I paste a line of code containing a string into Xcode. for example when I pasted this into Xcode:
simonLabel.text = #"Good Job!";
I received an error saying that there was an "unexpeceted '#' in program"
If I delete everything and retype exactly the way I pasted it I do not get an error.
There are too many problems that can appear there:
" can be a different character that you expect
(space) can be a different character that you expect
invisible characters. Something you won't see in the editor at all but they got there with the copy-paste.
All these problems can happen because
You copy it from a website with different encoding (or from a really badly writter website)
You copy it from a smart editor (e.g. MS Word, Open Office) which replaces some of the characters to match locale (e.g. quotation marks) or replaces/add spaces based on grammar and word wrapping (e.g non-breaking space).

Winforms problem with codepage "?" char instead of apostrophe '

In .NET 3.5, I have a Winform with a combobox in it. The datya comes from a DB2 mainframe DB. The problem is that we have a character that is not the real apostrophe. Pasted from Word I'd guess. But in our combobox, it is not diplayed correctly. It shows a question mark "?" instead.
Any idea on how could I get it to display the character as it is ?
First you should check if the character is intact in the database, or if the problem is that the code page doesn't support the character.
If the code page used in the database doesn't support the character, it has been replaced with a question mark, and the data is lost. The best you could do in that case is to try to figure out which question marks are the result of data loss, and which are supposed to be question marks, and try to recreate the data.
If the character is intact in the database, you should just need to make sure that the font used to display the text supports unicode.
Note: The character used is probably a typographic apostrophe like unicode character U+2019.