|
-
Jan 11th, 2006, 04:10 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] trim doesnt work -vba outlook
hey,
does anyone has any idea why trim (StrVar) doesn't remove the spaces in the begining and in the end of the string.
the code is simple:
StrVar = right (Item.Body,50)
StrVar = trim (StrVar)
msgbox StrVar "before" & StrVar & "after"
for the body ending in " 1234 " I still get the same string with all the spaces
I'm sure this is really stupid, but I still can't see how...
thanks,
-
Jan 11th, 2006, 07:46 PM
#2
Re: trim doesnt work -vba outlook
Try using a secondary variable to hold the new trimmed value.
VB Code:
Dim StrVar As String
Dim StrVar2 As String
StrVar2 = Trim$(StrVar)
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 
-
Jan 12th, 2006, 04:06 PM
#3
Thread Starter
Fanatic Member
Re: trim doesnt work -vba outlook
Thanks for the tip - I tried it but it Still doesn't work.
-
Jan 12th, 2006, 05:07 PM
#4
Re: trim doesnt work -vba outlook
Are you buffering the StrVar with a fixed length or anything?
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 
-
Jan 12th, 2006, 07:16 PM
#5
Thread Starter
Fanatic Member
Re: trim doesnt work -vba outlook
not that I know of.
my code is as simple as shown above: I need to look for two certain strings in the body of an email item (outlook) and then operate upon them ignoring any spaces chars between them.
-
Jan 13th, 2006, 01:49 AM
#6
Re: trim doesnt work -vba outlook
Just realized that your using Right. That will buffer a string of 50 chars as the way you have it setupo.
Use RTrim instead to trim blank spaces from the right side of a string.
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 
-
Jan 13th, 2006, 05:02 AM
#7
Thread Starter
Fanatic Member
Re: trim doesnt work -vba outlook
I'm using right to get the end of the body, and from that end I need to trim the spaces (and then Instr for the two strings).
-
Jan 13th, 2006, 06:18 AM
#8
Addicted Member
Re: trim doesnt work -vba outlook
Try to put out that 50 character value in some of the control , i think text box would be best , just shift that value in the hided text box or some thing and then use the TRIM function , i think u can then achive ur required task.
-
Jan 13th, 2006, 11:10 AM
#9
Re: trim doesnt work -vba outlook
You can use InstrRev and Mid$ to parse a string from the right side. Otherwisae your code is not going to work because of the buffering of the string variable.
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 
-
Jan 13th, 2006, 08:16 PM
#10
Thread Starter
Fanatic Member
Re: trim doesnt work -vba outlook
I don't know what exactly the string will contain, so I need to Instrdev to everything besides " "
-
Jan 13th, 2006, 11:26 PM
#11
Re: trim doesnt work -vba outlook
Why not just get it all instead of getting from the end back to some point?
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 
-
Jan 15th, 2006, 04:53 AM
#12
Thread Starter
Fanatic Member
Re: trim doesnt work -vba outlook
because there's always a chance that similiar strings will be in the body of the text, while I'd like to act upon the strings at the end of the text.
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
|