Results 1 to 10 of 10

Thread: [RESOLVED] Insert this chacter in a string: &

  1. #1

    Thread Starter
    Hyperactive Member anna7's Avatar
    Join Date
    Sep 2005
    Location
    Catalonia
    Posts
    481

    Resolved [RESOLVED] Insert this chacter in a string: &

    Hi

    how I can insert this character in a string: &

    I tried this:

    example:

    "Manolitos " & "&" & " Co."
    but it displays error end instruction was waited


    Regards

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Insert this chacter in a string: &

    Hmm - I don't get the error, but also why not just have it entirely enclosed in quotes.

    Can you show us your code.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Insert this chacter in a string: &

    How about
    Code:
     Label1.Text = "Manolitos " & "&&" & " Co."

  4. #4
    Addicted Member
    Join Date
    Jul 2008
    Location
    Altoona, PA
    Posts
    242

    Re: Insert this chacter in a string: &

    Quote Originally Posted by Hack View Post
    How about
    Code:
     Label1.Text = "Manolitos " & "&&" & " Co."
    Yeah that's what i was thinking might be the problem, but it shouldn't cause an error if you only have 1.

    Why not enclose the entire string in quotes?

  5. #5

    Thread Starter
    Hyperactive Member anna7's Avatar
    Join Date
    Sep 2005
    Location
    Catalonia
    Posts
    481

    Re: Insert this chacter in a string: &

    the text to insert a in a string is this:

    CType(sender, XRLabel).Text = "Page " & PageNumber.ToString() & " of " & PageCount.ToString()
    (I need to replace .vb file and I need insert a new line code)


    regards

  6. #6
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Insert this chacter in a string: &

    Quote Originally Posted by Hack View Post
    How about
    Code:
     Label1.Text = "Manolitos " & "&&" & " Co."
    I must be missing something, because this works perfectly well :

    Code:
    Label1.Text = "Manolitos & Co."
    Of course you need to set the UseMnemonic property to false in order to show the apersand in a control like a label, but even without doing that there is no error.

  7. #7
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Insert this chacter in a string: &

    Quote Originally Posted by anna7 View Post
    the text to insert a in a string is this:



    (I need to replace .vb file and I need insert a new line code)


    regards
    I don't see anywhere in that example where you would be putting an "&" within the string.

  8. #8

    Thread Starter
    Hyperactive Member anna7's Avatar
    Join Date
    Sep 2005
    Location
    Catalonia
    Posts
    481

    Re: Insert this chacter in a string: &

    I need to insert this text (exact) in a string:

    myString="CType(sender, XRLabel).Text = "Page " & "&" & "PageNumber.ToString()" &" &" & " of " & " & " & "PageCount.ToString() "


    Output will be this:

    CType(sender, XRLabel).Text = "Page " & PageNumber.ToString() & " of " & PageCount.ToString()

  9. #9

    Thread Starter
    Hyperactive Member anna7's Avatar
    Join Date
    Sep 2005
    Location
    Catalonia
    Posts
    481

    Re: Insert this chacter in a string: &

    finally I've solved this issue:
    myString = "CType(sender, XRLabel).Text = ""Página "" & PageNumber.ToString() & "" de "" & PageCount.ToString()"
    and output:
    CType(sender, XRLabel).Text = "Page " & PageNumber.ToString() & " of " & PageCount.ToString()

  10. #10
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] Insert this chacter in a string: &

    OK your problem isn't with the "&" it's with the quotes. VB will treat the "Page" as a keyword as it isn't inside the quotes.

    EDIT - sorry, too slow in my typing !

    That just illustrates why its a good idea to show your code at the start!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width