CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2014
    Posts
    8

    Basic TextBox Question: Combine string and integer in one line/statement

    This code works:
    listBox1.Items.Add("Index of First File Name Char: ");
    listBox1.Items.Add(index1);

    If int index1 contains the value 10, then this code prints:

    Index of First File Name Char:
    10


    So, how do I do both in one statement? ...and print both on the same line?
    I tried casting and ToString, but can't get the right syntax.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Basic TextBox Question: Combine string and integer in one line/statement

    Code:
    listBox1.Items.Add(String.Format("Index of First File Name Char: {0}", index1));

  3. #3
    Join Date
    Feb 2014
    Posts
    8

    Re: Basic TextBox Question: Combine string and integer in one line/statement

    Great! Thanks.
    No idea why I looked for so long without seeing that....

    By the way... Loaded the code you gave me for making a List with thousands of file names. Worked until the last line where it gave me a "file not found" error. I'll play with it and get back if I can't figure it out.

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

Featured