Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HELP with Program

StatsStats Posts: 1Member
I have a program that I need help with.

Write a program that allows the user to use a button to toggle the color of
the text in a text box between black and red.

Can anyone help?

Comments

  • pseudocoderpseudocoder Posts: 673Member ✭✭
    You could declare a boolean and set its initial value to true or false. under the button's onclick event, check the boolean with an if/else; for example, if it's true, set the color to black or if it's false, set the color to red. before the exiting the sub, negate the boolean.




  • fashdeefashdee Posts: 13Member
    [color=Blue]Private Sub[/color] Button2_Click([color=Black]ByVal[/color] sender [color=Blue]As[/color] System.[color=Green]Object[/color], ByVal e _
    [color=Blue]As[/color] System.[color=Green]EventArgs[/color]) [color=Blue]Handles[/color] Button2.Click
    [color=Blue]If[/color] TextBox1.ForeColor = [color=Green]Color[/color].Red Then
    TextBox1.ForeColor = [color=Green]Color[/color].Black
    [color=Blue]Else[/color]
    TextBox1.ForeColor = [color=Green]Color[/color].Red
    [color=Blue]End If[/color]
    [color=Blue]End Sub[/color]
  • swpcswpc Posts: 1Member
    It will work without "Else
    TextBox1.ForeColor = Color.Red"


    [grey][size=1][link=http://www.badgerbadgerbadger.com/]aplikacje internetowe[/link][/size][/grey]
Sign In or Register to comment.