HELP with Program

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?


  • 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.

  • [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
    TextBox1.ForeColor = [color=Green]Color[/color].Red
    [color=Blue]End If[/color]
    [color=Blue]End Sub[/color]
  • It will work without "Else
    TextBox1.ForeColor = Color.Red"

    [grey][size=1][link=]aplikacje internetowe[/link][/size][/grey]
Sign In or Register to comment.

Howdy, Stranger!

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