I have a problem... how do you pull a " out of a string??? cuz you cant just put""" cuz it just thinks you put too many "... anyone have an idea on what i can do?
Printable View
I have a problem... how do you pull a " out of a string??? cuz you cant just put""" cuz it just thinks you put too many "... anyone have an idea on what i can do?
you can use "'s in strings
try this:
VB Code:
Private Sub Form_Load() MsgBox """" End Sub
what probs you got?
can you show us the line of code that your stuck with?
Not sure what exactly your trying to do but you could use it's Ascii value. " = 34 *I think*
JO
ok what i'm doing here is a web page that allows users to type what ever they want... now it they type a " in the middle... sql thinks that is the end of the string and disreguards everthing else after that... what i want to do is scan the string for " and replace them with ## and when it is displayed again on a differnt screen change the ## back to " do you understand now??? this is being written to an access database... and the field type is memo.....
myString = Join(Split(myString, """"),"##")
To reassemble when reading
myString = Join(Split(myString, "##"),"""")
that wont work... i need it to pull out all " not "" your code will only work for double " .... andit dosent allow you to do """ it bombs out thinking you errored it..
here is my error
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/testweb/BulletinBoard/BulletinBoardposting.ASP, line 38
Descriptions = Replace(Descriptions, """, "##")
-------------------------------------------^
etc...etc...VB Code:
'Replace " with * strTest = Replace(strTest,""""."*") 'or replace it a " with "": strTest = Replace(strTest,""""."""""") 'or replace it with '' (two single quotes): strText = Replace(strTest,""""."''")
you dont seem to undstand.... you all are useing 4 """" where what i need is 3 """ and the system does not like this at all...
No, YOU don't understand.
have you even tried the code you were given?
The occurance of two quotes WITHIN a quoted string collapses to one quote.
Microsoft VBScript compilation error '800a03f2'
Expected identifier
/testweb/BulletinBoard/BulletinBoardposting.ASP, line 38
Descriptions = Replace(Descriptions,""""."*")
-----------------------------------------^
and your code does nothing either 4" does not colapes to 3" have you tried your own examples to see if they work in script????? none of these exampls work... either they error out like up top or i lose all the text after the first "
Frankly, your ineptitude never ceases to amaze me.
A) You never indicated until just now that you were programming in ASP. This does make a difference.
B) You have no clue what you are talking about.
You will need to do it the long way.
While Instr(theString, """") > 0
theString = Left(theString, InStr(theString, """") - 1) & "##" & Mid(theString, inStr(theString, """") + 1)
Wend
Now, I don't have an ASP page on-hand, but this is close if not exact, where theString is the string yoy have the quotes in.
use this VB script function (I've used it countless times). It will make any type of data SQL safe.
VB Code:
'------------------------------------------------------------------------------- '<*| ' function SSquote ' SQL Server database prep function ' ' This routine makes a string SQL safe. It should be used RELIGIOUSLY ' whenever SQL Strings are put together in ASP code. If you do not use ' this function (or something like it) in your SQL statements you are probably ' causing a MAJOR security hole by appending user input directly onto ' a SQL Statement which is passed into the database server's ' parsing engine. Additionally if you don't use this routine database portability ' and/or database upgrades can be VERY difficult. ' ' Usage Example: ' ' SQL = "INSERT INTO tblUsUser (UsID, UsWebCookie, UsDateCreated, UsBrowser, UsWantsEmail) VALUES (" ' SQL = SQL & quote(UsID, SSNUM)& ", " ' SQL = SQL & quote(UsWebCookie, SSSTR)& ", " ' SQL = SQL & quote("", SSDATENOW)& ", " ' SQL = SQL & quote(request("HTTP_USER_AGENT"),SSSTR)& ", " ' SQL = SQL & quote(request("EmailOK"), SSBOOL) & ")" ' Parameters: ' *string[string] ' value to be prepped ' *int_flag[integer] ' SSSTR = 0 ' This denotes a String or Character variable. It handles escaping single ' quotes and deals with NULLs correctly. The string which is passed ' is returned enclosed in single quotes, so don't include them in the ' SQL statement. ' SSNUM = 1 ' This denotes a Numeric variable (int, long, float, money, percent, etc...) ' Dollar signs an commas are removed. If the string passed is not ' numeric then a NULL is returned for insertion. ' SSDATE = 2 ' This denotes a Date value for use in an INSERT or WHERE clause. ' Note that there is no differentiation between INSERT and WHERE dates ' SSBOOL = 4 ' This denotes a Boolean variable. "true", "yes" or "1" (case insensitive) ' are all returned as TRUE for the particular database. All other values ' are returned as FALSE. ' SSDATENOW = 5 ' This flag is slightly different from the above in that it is used to ' default a date field to the date from the clock of the database server. ' It is important to use this flag and not the VB Script now() function ' where accurate timing is required. When this flag is used the string ' parameter can be used to specify the offset (in days) from the current ' system date of the database. ' SSLIKE = 6 ' For LIKE in a query ' Surrounds string with '% <string> %' 'Output: ' *[string] ' outputs the DB prepped string '/|*> '------------------------------------------------------------------------------- function SSQuote(byval string, int_flag) if (string <> "") then string = replace(string, chr(39), chr(39)&chr(39)) 'change apostrophes to double apostrophes string = replace(string, chr(34), chr(34)&chr(34)) 'escape double quotes string = replace(string, "|", "") 'strip out pipes Select Case int_flag Case SSSTR ' String variable handling SSQuote = "'" & trim(string) & "'" Case SSNUM ' Do some string cleaning for numeric fields string = replace(string, ",", "") string = replace(string, "$", "") if (NOT IsNumeric(string)) then SSQuote = "NULL" else SSQuote = string end if Case SSDATE ' SQL Server Date syntax SSQuote = "'" & trim(string) & "'" Case SSBOOL ' Boolean variable handling if (lcase(string) = "true" or lcase(string) = "yes" or string = "1") then SSQuote = 1 else SSQuote = 0 end if Case SSDATENOW ' SQL Server System Date SSQuote = "DATEADD(day, " & string & ", GETDATE()) " Case SSLIKE ' String variable handling SSQuote = "'%" & trim(string) & "%'" End Select else ' Handle the case where string is empty Select Case int_flag Case SSDATENOW ' SQL Server System Date SSQuote = "GETDATE() " Case SSBOOL SSQuote = 0 Case SSSTR SSQuote = "''" Case SSNUM SSQuote = "NULL" Case SSDATE SSQuote = "NULL" Case SSLIKE SSQuote = "'%%'" End Select end if end function
Rat you sure are arrogantly dense
>>>Frankly, your ineptitude never ceases to amaze me.
>>>>A) You never indicated until just now that you were >>>>programming in ASP. This does make a difference.
Look up i showed you the error was an asp page....
>>>>B) You have no clue what you are talking about.
So i have no clue what i'm talking about when i take your code paste it in and change the var name to the one i'm using and it dosent work... i show the the freggan error and you have the nerve to tell me this?????? then if your code is so great why did you have to change it??
>>>Now, I don't have an ASP page on-hand, but this is close if >>>not exact, where theString is the string yoy have the quotes in.
and if your such a genius why cant you just whip up an asp page... or a vb script
And if you had any sense at all, we would not have reached this point in the conversationQuote:
Originally posted by Filter300
Rat you sure are arrogantly dense
Becuase I wrote it for VB for Apps since you never indicated you were using ASP. :rolleyes:Quote:
So i have no clue what i'm talking about when i take your code paste it in and change the var name to the one i'm using and it dosent work... i show the the freggan error and you have the nerve to tell me this?????? then if your code is so great why did you have to change it??
FineQuote:
and if your such a genius why cant you just whip up an asp page... or a vb script
I did and it worked exactly as I wrote in the above post.
See attached.
Filter300.....You sure are complaining alot to think that your asking for someone elses help, who is obviously trying to help you.
You should remember it is YOU that has presented YOUR problem not everyone else, these people are only trying to help you.
If you don't like their answers or suggestions try investigating it yourself or buy a book.
It's free information, and beggers can't be choosey
I'm sorry I imposed, but it's frustrating to sit back and see people trying to help someone and even if it is not successful not even appreciating the effort.
I spoke out because SO MANY people have helped me SO MANY times in this forum and I appreciate every one of them, even the ones that were not successful - at least they tried.
Once again I'm sorry if I imposed...
JO
rat if you would have read my original post you can see that i'm asking for a way to remove " not "" your asp page
<%@Language = "VBScript"%>
<%
Dim theString
theString = "Descretion is the better part of ""valor""."
response.Write(theString & "<br>")
While Instr(theString, """") > 0
theString = Left(theString, InStr(theString, """") - 1) & "##" & Mid(theString, inStr(theString, """") + 1)
Wend
response.Write(theString)
%>
only works for "" thats not what i asked about at all...
and joltremari, if you would read the posts quote rat here"Frankly, your ineptitude never ceases to amaze me. " was completely uncalled for... what i asked for from the start was to remove " not "" and you 2 dont seem to understand that.
i didnt say anything bad twards him till he had to cop an attitude
Did you even run the page?
You will see that the output only contains one " not two.
Filter300, why not try the funtion I provided, it works!
ok... i got it working now... thanks for the help
Can't we all just get along *holds up a nice peace sign* :D
And apparently, YOU didn't read HIS post:Quote:
Originally posted by Filter300
rat if you would have read my original post you can see that i'm asking for a way to remove " not "" your asp page
:rolleyes:Quote:
Originally posted by Lord_Rat
The occurance of two quotes WITHIN a quoted string collapses to one quote.