Results 1 to 3 of 3

Thread: [2005]Simple Concatenation

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    274

    [2005]Simple Concatenation

    VB Code:
    1. MsgBox(tboxFirstName.Text + tboxLastName.Text + "has been deleted", MsgBoxStyle.Exclamation, "Delete")

    This code outputed with the firstname and lastname stating has been delete...My question is how can I put a space between firstname and lastname as well as to the string "has been deleted"?thanks in advance....

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

    Re: [2005]Simple Concatenation

    You are joining strings together. If you want another string in between the first name and last name then just put an extra string in there: one that contains a single space. Also, if you want a space before the word "has" then just put one in the string. You've got a space after the word so why can't you put one before it?

    Note that you may also want to consider using the "&" operator instead of "+". You may also like to investigate the String.Format method, which makes things much more readable when concatenating multiple strings.
    Last edited by jmcilhinney; Jun 22nd, 2006 at 01:39 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: [2005]Simple Concatenation

    You just need to add a space character!

    Give this a whirl

    VB Code:
    1. MsgBox(tboxFirstName.Text & " " & tboxLastName.Text & " has been deleted", MsgBoxStyle.Exclamation, "Delete")

    You might also want to consider using Windows.Forms.MessageBox.Show(..), instead of MsgBox.

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