Invert Colors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Oubez
    New Member
    • Mar 2008
    • 2

    Invert Colors

    hi guys,

    I need to invert colors of a text box and its text that's background color of text area becomes the color of the characters and vice versa.

    I tryed this but it didn't work

    TextBox.BackCol or = TextBox.ForeCol or
    TextBox.ForeCol or = TextBox.BackCol or

    they both had the same color :S
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    With your Code, ForeColor is already Changed To BackColor, So both becomes same..

    Use a Temp Variable

    [code=vb]

    Dim TStr As String
    TStr = TextBox.BackCol or
    TextBox.BackCol or = TextBox.ForeCol or
    TextBox.ForeCol or = TStr
    [/code]

    Regards
    Veena

    Comment

    • Oubez
      New Member
      • Mar 2008
      • 2

      #3
      hey,

      when I tryed that it gave an error:

      Value of type 'System.Drawing .Color' cannot be converted to 'String'

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        It is a TypeCasting error. VB6 is a Winner in handling such cases. It automatically Type casts variable to appropriate type..without generating any such error..
        Any way with VB.net, you have to declare properly, Or use Variants:

        [code=vbnet]
        Dim tstr
        tstr = TextBox1.BackCo lor
        TextBox1.BackCo lor = TextBox1.ForeCo lor
        TextBox1.ForeCo lor = tstr
        [/code]

        REgards
        Veena

        Comment

        Working...