Solved

& Character

Posted on 2003-12-02
4
188 Views
Last Modified: 2010-05-01
Simple question, but my brains gone numb and I cant think of the code I need!

Im getting data from a database that has a & in it. E.g. One & Two

However when I display this in a label it shows as One _ Two,

Any help much appreciated.
0
Comment
Question by:Terry Rogers
[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
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 9856668
I guess you'll have to replace every & character by 2 &-characters. Give it a try and let me know what you get then....
0
 
LVL 6

Accepted Solution

by:
rvooijs earned 100 total points
ID: 9856678
Hi,

If you want this text to be displayed in a label, you will have to replace the & with &&.

something like:
    myLabel.caption = replace(myText, "&", "&&").

One other option would be to use a textbox in stead of a label. Make the background transparent, disable and lock it, and it behaves like a label.

Any good ?

Robert
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 9857007
Didn't I say exactly the same thing ?
0
 

Expert Comment

by:josebirla
ID: 9857124
make a condition just before in order to find out the precense of & in the field and use replace function


eg.  if instr(1, rs(fieldName).value, '&') then
              str=replace(rs(fieldName).value, "&", "&&")
      else
             str= rs(fieldName).value
      end if
     label1.caption=str


   
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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 …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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