Solved

How to correct spaces in brackets

Posted on 2004-10-20
9
276 Views
Last Modified: 2010-05-02
Is there any way to delete spaces at the start of bracket and end of brackets while changing the Font Style of brackets and contents seperately through VB.
0
Comment
Question by:micazone
9 Comments
 
LVL 2

Assisted Solution

by:koolnurd
koolnurd earned 50 total points
ID: 12366514
try using

trim(string)

trim is a function which remove spaces from the begining and end of the string.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 12366750
Can you give us an example?
0
 
LVL 2

Assisted Solution

by:craigewens
craigewens earned 200 total points
ID: 12367521
Try something like this:

Function RemoveBracketSpaces(txtInput As String) As String
    RemoveBracketSpaces = Replace(Replace(txtInput, "( ", "("), " )", ")")
End Function

Craig
0
 
LVL 2

Accepted Solution

by:
craigewens earned 200 total points
ID: 12368153
With regards to having different fonts within the same object, i guess it'd depend on the object your trying to use. A label for example can't do this (AFAIK). The way i'd get round this though is to split your string into 3 parts. Here are three functions to do this for you.. use them and populate 3 different labels having the fonts any way you wish... just place them next to each other so they look like one :)

Function LeftString(txtInput As String, txtSearch As String) As String
    LeftString = Left(txtInput, InStr(1, txtInput, txtSearch) - 1)
End Function
Function RightString(txtInput As String, txtSearch As String) As String
    RightString = Right(txtInput, Len(txtInput) - InStrRev(txtInput, txtSearch))
End Function
Function MidString(txtInput As String, txtSearchStart As String, txtSearchEnd As String) As String
    MidString = Mid(txtInput, _
            InStr(1, txtInput, txtSearchStart) + 1, _
            Len(txtInput) - InStr(1, txtInput, txtSearchStart) - (Len(txtInput) - InStrRev(txtInput, txtSearchEnd)) - 1)
End Function
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:micazone
ID: 12369130
Thanks
How to put in sub or make a full script.
I am not a programmer hence this help needed.
0
 
LVL 2

Expert Comment

by:craigewens
ID: 12369250
Post a sample of your code with comments directing where you'd like the operations to take place. Eg...

code blaa
code blaa
code blaa
' now make my variable txtTempString have no spaces
code blaa
code blaa
' now put my variable txtTempString into label1.caption
code blaa
code blaa


etc etc
0
 

Author Comment

by:micazone
ID: 12371881
I have to replace and fomat all the text srings within brackets in a document, possibly a wild card type.
i.e. need to remove spaces before and after text string present in the document.
0
 

Author Comment

by:micazone
ID: 12381490
Please help with a macro please
0
 

Author Comment

by:micazone
ID: 12387281
Can the following work? Sorry I am not and expoert or programmer.
Sub correctBrackets()
Function LeftString(txtInput As String, txtSearch As String) As String
    LeftString = Left(txtInput, InStr(1, txtInput, txtSearch) - 1)
End Function
Function RightString(txtInput As String, txtSearch As String) As String
    RightString = Right(txtInput, Len(txtInput) - InStrRev(txtInput, txtSearch))
End Function
Function MidString(txtInput As String, txtSearchStart As String, txtSearchEnd As String) As String
    MidString = Mid(txtInput, _
            InStr(1, txtInput, txtSearchStart) + 1, _
            Len(txtInput) - InStr(1, txtInput, txtSearchStart) - (Len(txtInput) - InStrRev(txtInput, txtSearchEnd)) - 1)
End Function
End Sub
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now