|
-
Feb 16th, 2005, 01:10 PM
#1
Thread Starter
Junior Member
Resolved--String manipulation in VBA
Hi ppl,
I have following situation. I have a form containing First name text box and the last name text box. When I press confirm button on this form, it concatenated First name and the last name to give me full name as a parameter that I am passing to the next form. However, problem comes if a user has last name like "O'Neil" or "O'Hair" or "O'Dell" the compiler does not understandd that apostrohy sign and gives me a runtime error.
Does anyone know how do I access such string which contains characters such as " " " , " ' ", "`"
Thanks in advance,
Vikram Bartakke
Last edited by vikram.bartakke; Mar 7th, 2005 at 03:40 PM.
-
Feb 16th, 2005, 01:36 PM
#2
Re: String manipulation in VBA
Usually we see this issue when dealing with a query to a db. To get around that we would just
double up on the single quote using the replace function.
VB Code:
strString = txtFirst & "," & txtLast
strString = Replace(strString, "'", "''")'
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 16th, 2005, 01:42 PM
#3
Re: String manipulation in VBA
 Originally Posted by vikram.bartakke
Hi ppl,
I have following situation. I have a form containing First name text box and the last name text box. When I press confirm button on this form, it concatenated First name and the last name to give me full name as a parameter that I am passing to the next form. However, problem comes if a user has last name like "O'Neil" or "O'Hair" or "O'Dell" the compiler does not understandd that apostrohy sign and gives me a runtime error.
Does anyone know how do I access such string which contains characters such as " " " , " ' ", "`"
Thanks in advance,
Vikram Bartakke
To place (") in a String in VB, use (""). ie..
VB Code:
strText = "This ""String"" Contains double-quotes"
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Feb 16th, 2005, 04:12 PM
#4
Thread Starter
Junior Member
Re: String manipulation in VBA
Hi ppl,
Thank you very much for your help. It worked fine. I knew about this problem but the time when i actually implemented this application i was ignorant
Ignorance is not bliss always )
-
Feb 16th, 2005, 04:35 PM
#5
Re: String manipulation in VBA
We were glad to have helped 
Ps, dont forget to Resolve your thread
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|