Results 1 to 7 of 7

Thread: Use of Chr(32)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Use of Chr(32)

    Hello

    When my SMTP (HTML) script emails a user, the user sees this: HelloUsersEmail (all one word), so I am trying to create a space between the word Hello and the users' email address by using Chr(32) as follows:

    Code:
    ("Hello", Chr(32), & strEmailValue & ",<br /><br /> " & "To reset your password, please click on this <a style='color:#22BCES5' href=''>link.</a>", Nothing, "text/html")
    but Visual Studio gives me a blue line under that first ampersand: 'Expression Expected'.

    What am I missing, please?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Use of Chr(32)

    You're missing the fact that you have a comma after 'Chr(32)' so that first ampersand isn't actually concatenating to anything.

    That said, why use Chr(32) at all when you can just use a literal space? You should learn to use String.Format or, even better in later versions, string interpolation. Also, it's just plain silly to concatenation two literal Strings together. Why would you ever use this:
    Code:
    ",<br /><br /> " & "To reset your password, please click on this <a style='color:#22BCES5' href=''>link.</a>"
    in preference to this:
    Code:
    ",<br /><br /> To reset your password, please click on this <a style='color:#22BCES5' href=''>link.</a>"

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Use of Chr(32)

    Thanks JmCilhinney

    Your preference is preferable.

    In relation to the space issue, this code:

    Code:
    "Hello" & "strEmailValue" & "
    which actually has a space between "Hello"[space]"strEmailValue" is the one that generate this 'HelloUserEmail' (all one word).

    I can check it again to be sure.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Use of Chr(32)

    Thanks JmCilhinney

    Your preference is preferable.

    In relation to the space issue, this code:

    Code:
    "Hello" & "strEmailValue" & "
    which actually has a space between "Hello"[space]"& is the one that generate this 'HelloUserEmail' (all one word).

    I can check it again to be sure.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Use of Chr(32)

    Yes, just as I thought.

    This code:

    Code:
    ("Hello" & strEmailValue & ",<br /><br /> To reset your password...
    with the space between "Hello" and the ampersand:

    Name:  blueArrow.jpg
Views: 128
Size:  14.7 KB

    produces this in my mail box:

    Name:  mailbox.jpg
Views: 114
Size:  12.7 KB

    Thanks for your advice.

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Use of Chr(32)

    unless the space is INSIDE the string IT DOESN'T count...

    Code:
    ("Hello " & strEmailValue & ",<br /><br /> To reset your password...
    See how there is now a space immediately after Hello? THAT is what was meant by needing a space...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2014
    Posts
    469

    Re: Use of Chr(32)

    Grateful thanks, techgnome

    You have cracked it.

    I have been on this for hours - a lesson well learnt.

    Thanks again

    PS: I still get this message from the board: 'You must spread some Reputation around before giving it to techgnome again.'

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