Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to correct spaces in brackets

Posted on 2004-10-20
9
Medium Priority
?
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 2

Assisted Solution

by:koolnurd
koolnurd earned 150 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 600 total points
ID: 12367521
Try something like this:

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

Craig
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Accepted Solution

by:
craigewens earned 600 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
 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

610 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