Results 1 to 3 of 3

Thread: Error in the code

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    47

    Error in the code

    Hey guys, while I was coding for my application. I ran into a problem
    Here's my code
    Code:
    outputTextBox = outputTextBox & 
    (counter + 1).ToString().PadLeft(2) & TotalSales(counter).ToString("C2").PadLeft(16) & bonus(counter).ToString("C2").PadLeft(17)
     & ControlChars.NewLine
    It says " Operator '&' is not defined for types 'System.Windows.Forms.TextBox' and 'String"

    Any help is appreciated! =)

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

    Re: Error in the code

    Think about what you actually want to do. Do you really want to join a String to a TextBox, or do you actually want to join a String to the contents of the TextBox? If it's the latter, how do you access the contents of a TextBox? Also, what do you really want to do with the result? Do you really want to replace the existing TextBox, or do you actually want to replace the contents of the TextBox?
    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

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    47

    Re: Error in the code

    Thanks I actually figured it out.

    Code:
    outputTextBox.Text = outputTextBox.Text & Bonustable(row, 0).ToString.PadRight(3) & Bonustable(row, 1).ToString("c0").PadLeft(12) & Bonustable(row, 2).ToString("c0").PadLeft(12) & ControlChars.NewLine

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