Link to home
Start Free TrialLog in
Avatar of micazone
micazone

asked on

How to correct spaces in brackets

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.
SOLUTION
Avatar of koolnurd
koolnurd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you give us an example?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of micazone
micazone

ASKER

Thanks
How to put in sub or make a full script.
I am not a programmer hence this help needed.
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
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.
Please help with a macro please
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