Put A Single Double Quote As A String?
Mar 15, 2011It would seem to be Dim MyString as String = """""" but VB doesn't like that.
View 2 RepliesIt would seem to be Dim MyString as String = """""" but VB doesn't like that.
View 2 RepliesI am saving a text field that may contain a single of double quote.' or "If i use a double quote in my SQL save funciton I can save and use single Quotes. When I use a Single quote I can save Double Quotes. Yet not both.People use both, so I would like to know how I could change the delimiter to something other than a Double Quote for my text saves
View 3 RepliesI have a CSV file where the values are in double quotes and seperated by a comma. I'm getting incorrect data if I try to seperate the string with my Split function. How do I do it?
Example:[code...]
I have a problem that seems trivial. In an argument to an activity I need to supply a path.
This is done by this code:
String.Format("a
-bd -y -tzip {0} {1}* -r",
Path.Combine(BinariesDirectory,
"output.zip"),
BinariesDirectory)
However, the directories parameters contain spaces so they have to have quotes around them. I tried with single quote ' that works fine to put in the string, but the command shell executing the command ignores these. So it has to be double quote "
I have tried all methods I have fount on the Internet, for example to have a backslash before the double quote and to have three double quotes, but nothing seems to work. I get a compiler error as below.
Error 4 Compiler error(s) encountered processing expression "String.Format("a -bd -y -tzip "{0}" '{1}*' -r", Path.Combine(BinariesDirectory, "output.zip"), BinariesDirectory)".Comma, ')', or a valid expression continuation expected.
I noticed that if I leave off the terminating double quote for a string constant in Visual Studio 2010, there is no error or even a warning, i.e.
Dim foo as String = "hi
However, the continuous integration tool we are using flags an error:
error BC30648: String constants must end with a double quote.
Is there some language rule in VB.Net that makes a terminating double quote optional "sometimes"? Is there some setting in Visual Studio that will make it flag this as an error, so I can avoid "breaking the build" in this way?
While searching on how to escape a single quote in String.Format, I found the answer at SO: Escaping single quote in String.Format(). It seems to be different for VB though. I tested it, and indeed C# needs
string s = DateTime.Now.ToString("MMM d \'yy 'at' H:mmm");
while VB needs
Dim s As String = Now.ToString("MMM d 'yy 'at' H:mmm")
Why does C# need a double backslash, and VB a single backslash? This might be a bit of a silly question to C# users, but while I can read C#, I'm not used to writing it.
I am trying to replace "a" to = ""a""
code i have tried is
If line.Contains("""") Then
line.Replace("", "")
[code].....
In vb.net, im using objWriter.Write("playerA= "x"")as you can see im using double quotes inside double quotes, how do i skip it so the error doesnt show up?in php you make an "" to skip the string like ("playerA = "x" ")
View 6 RepliesI use SqlParameters when executing database statements. I know that I can replace a single quote with two single quotes... but in the past SqlParameters took care of this for me. I have two projects.. in one, the SqlParameter does this and it handles single quotes fine, in another, it does not and I'm at a loss why (I even copied and pasted the code):
[Code]...
If my string is "1,60299" getting collection of UserCodes .... then if I want to remove " from both ends what do I have to do ??ex: strUserCode = "1,62099,100156321"
View 3 RepliesI have a problem with double and single quotes in a string.I have a textbox where i take a string from.In the textbox are double quotes and single quotes quotes.Problem is that if i return the string all the single quotes are replaced by double quotes.How can i get it to keep the single quotes as single quotes?
View 4 Replieshow can i replace the double quote in vb.net?
View 3 RepliesI want to use this code. Is there anyway I can Double quote?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text = "Open Website" Then
[code].....
I'm extracting data to a text file (notepad) using VB system IO. I'm not sure what is wrong. When i extract the file from computer A, it is OK
Output:
Data A
Data B
Data C
Data D
But from PC B,
Output:
"Data A"
"Data B"
"Data C"
double quote appears on open and end of each lines.
How would I do a replace to replace a double quote with a blank space
What would I put in the ( ):
NameValueArgs.Item(i).ToString().Replace( )
I have this block of code that sets up my sql parameters for a stored proc that does an insert.
Dim sproc As StoredProcedure = New StoredProcedure("UsersInsert2", DataAccessConfiguration)
sproc.AddInput("@ID", SqlDbType.NVarChar, 10, entity.UserId)
sproc.AddInput("@PCode", SqlDbType.SmallInt, entity.PriviledgeCode)
sproc.AddInput("@Pwd", SqlDbType.NVarChar, 10, entity.Password.ToString())
[code]...
I've tested the stored proc in SSMS and it works.The problem is when I try to call it from the application. it fails. the @@rowcount = -1. I've tried returning an error code from the db... no dice. keeps coming back as -1 what is going to get executed looks like this
sproc = {EXEC UsersInsert2 @ID=ruxtest7, @PCode=0, @Pwd=1234, @Lang=E, @Name=ruxpint, @Notice=1, @CreatedBy=ruxpint}
I've re-used this code several times. only difference being I'm using NVarChar and it's vb.net.
I have a filter expression that contains a single quote (Al ' ABC), and i am using the Select statment of the datatable where i want to select all rows containing the filter expression, but i am encountering an error. how can i resolve it?
View 1 RepliesI have a filter expression that contains a single quote (Al ' ABC), and i am using the Select statment of the datatable where i want to select all rows containing the filter expression, but i am encountering an error. how can i resolve it
View 3 RepliesI'm trying to read a csv file with comma separated. Problem is inside the file, it has one column which original value already contains Comma. Here is the example
[Code]....
So, when I Split the string with Comma, it gave me problem. Actually total it has 6 columns. But because of internal comma, it gave me 7 columns. And this CSV format can't change so I must deal with this problem. And so here I come out with a solution (because of its too long, I looking for better idea and solutions from you guys ):
[Code]....
I have the following LINQ query:
Dim find_id = From p In dbContext.Residents _
Where p.person_name = occupant _
Select p
I then pull the first returned ID like so:
Dim building_id As String = find_building_id.FirstOrDefault.id
This works fine, except with the person has a ' in their last name, like M'arta. In this case I get a NullReferenceException.
Okay, the problem appears to be that when I am capturing the name initially from a GridView it is inserting into the value a #39 instead of ' and then LINQ is keeping things correct, so I end up with a non-match since it is attempting to match:
M#38arta = M'arta
I have a function in VB.NET that runs a query from an MS SQL DB, puts the results into temporary variables, then updates an Oracle DB. My question is, if the string in the MS SQL contains a single quote ( ' ), how do I update the Oracle DB for something that has that single quote?
For example: Jim's request Will produce the following error: ORA-01756: quoted string not properly terminated The ueio_tmpALM_Comments (coming from MS SQL) is the culprit that may or may not contain the single quote.
update_oracle =
"update Schema.Table set ISSUE_ADDED_TO_ALM = '1'," & _
"ISSUE_COMMENTS = '" & ueio_tmpALM_Comments & "'," & _
"where ISSUE_SUMMARY = '" & ueio_tmpALM_Summary & "' "
Dim or_cmd_2 = New NetOracle.OracleCommand(update_oracle, OracleConn)
or_cmd_2.ExecuteNonQuery()
I have a string like "Hello'World" and a Data Table with some records in it. One of those records is "Hello'World".he problem is, when I do a .Select in the Data Table, it only tries to search for the "Hello" part and throws an error on "World" because it interprets the ' (single. cuote) like the closing cuote on sql.DataTable.select("text = 'Hello'World'")I have gone through msdn doc, and it says I can escape some characters with [] brackets or f.slashes , but I just can't figure out: .select("text = 'Hello[']world'")
View 1 RepliesThe code is as follows
dim st as string
st="select * from employees where empName='" & textName.Text &"'"
' The empName is Dani'e
'So the single quote with in the name Dani'e makes the vb.net code to halt.
I have a situation where I am handling both single & double mouse click events on a form. In both cases something has to be loaded, however when a double click occurs, I do not wish to execute the code attached to the single click event.Is there a way to intercept the mouse click's and check if double or single and then execute the right event appropriately?
View 2 RepliesI read in a Byte Array generated from a function called from an external DLL file and then converted (encoded) it into a String. In the Locals window (shown below), msg does not have a trailing double-quote.[code]...
View 1 RepliesI'm trying to include quotes into my string to add to a text box, i am using this [code]....
View 5 Repliesis there way to update having quote string eg. drug's name ('s) in vb text field ' this corrector REFUSING TO UPDATE TO DATABASE. this kinds of error always comes up Incorect Syntax Near 'S'.Unclosed Quotation Mark After character string '))'.
View 3 RepliesHere's my test code:
Dim testSingle As Single = 7.2
Dim testSingleF As Single = 7.2F
Dim testDouble As Double = 7.2
[code].....
Follow-Up available: There's a follow-up with further details, see Convert MBF to IEEE.
I've got some legacy data which is still in use, reading the binary files is not the problem, the number format is. All floating point numbers are saved in MBF format (Single and Double). I've found a topic about that on the MSDN boards but that one only deals with Single values. I'd also would like to stay away from API-Calls as far as I can.
Edit: Just in case somebody needs it, here is the VB.NET Code (it's Option Strict compliant) I ended up with (feel free to convert it to C# and edit it in):
''' <summary>Converts a MBF Single to an IEEE Single</summary>
''' <param name="src">The MBF Single value</param>
''' <returns>The converted IEEE Single value</returns>
[Code]...
[Code]...
The code compiles and seems to run correctly, but is underlined with the message "Implicit Conversion from 'Double' to 'Single'" Why would this be an implicit conversion if each of the variables is cast as a Single? Is this something I should worry about or change?