Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
HELP with Program Posted by Stats on 17 Feb 2011 at 9:43 AM
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?

Report
Re: HELP with Program Posted by pseudocoder on 18 Feb 2011 at 7:17 AM
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.




Report
Re: HELP with Program Posted by fashdee on 8 Mar 2011 at 3:48 AM
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles Button2.Click
If TextBox1.ForeColor = Color.Red Then
TextBox1.ForeColor = Color.Black
Else
TextBox1.ForeColor = Color.Red
End If
End Sub
Report
Re: HELP with Program Posted by swpc on 17 Mar 2011 at 3:52 PM
It will work without "Else
TextBox1.ForeColor = Color.Red"


aplikacje internetowe



 

Recent Jobs