Howdy, Stranger!

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


HELP with Program

StatsStats Member Posts: 1
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?


  • pseudocoderpseudocoder Member Posts: 701 ✭✭✭
    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 Member Posts: 13
    [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]
  • swpcswpc Member Posts: 1
    It will work without "Else
    TextBox1.ForeColor = Color.Red"

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