相关于Microsoft Visual Basic [英] Related To Microsoft Visual Basic
本文介绍了相关于Microsoft Visual Basic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Name] = '" & Me![Combo81] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
上面的代码用于检查组合框以进行搜索
不带引号的名字.
我需要有个条件天气,这个名字要有撇号,不要用引号引起来.
1)如何检查天气名称是否有引号?
2)如果名称conatins
,我该如何写上面的代码呢?
->单引号('''')
->双引号(")
->撇号('')
谢谢
The above code is used to check for the combo box to search
for name without any quotes .
I need to have a conditon weather the name has apostrophe,quotes or not .
1)How do I check weather the name has any sort of quotes or not ?
2)How can I write the above code for the same ,if the name conatins
->single quotes ('''')
->double quotes ("")
->apostrophe('')
Thanks
推荐答案
请参阅此链接..它正在处理您所要求的情况. />
http://support.microsoft.com/kb/113955
Refer this link.. It is dealing with the situation you are asking for.. I all also put an updated solution once I get the code working
http://support.microsoft.com/kb/113955
Here is the code
First write two small helper functions to replace the single quote and double quote with chr(39) and chr(34)
Function DoParseQuote(ByVal sString As String) As String
Dim sTemp As String
sTemp = Replace(sString, "'", "' & Chr(39) & '")
DoParseQuote = sTemp
End Function
Function DoParseDoubleQuote(ByVal sString As String) As String
Dim sTemp As String
sTemp = Replace(sString, """", "' & Chr(34) & '")
DoParseDoubleQuote = sTemp
End Function
然后从搜索中调用该函数
Then call the function from search
str = "EmpName = '" & DoParseQuote("Don't") & "'"
str = "EmpName = '" & DoParseDoubleQuote("Milka ""speedy"" singh") & "'"
rs.FindFirst str
这篇关于相关于Microsoft Visual Basic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文