How to change the color of the text

Hi,

I have a text box where i display a text "Hello World" on the click of a button..I need to change the color of the text and display the entire text with different colors..
LVL 1
sramkrisAsked:
Who is Participating?
 
Chandramouli kArchitectCommented:
This might be useful.

Dim nRed As Integer, nGreen As Integer, nBlue As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Randomize
nRed = 255 * Rnd
nBlue = 255 * Rnd
nGreen = 255 * Rnd
Text1.ForeColor = RGB(nRed, nGreen, nBlue)
End Sub

kcm
0
 
COAtheGREATCommented:
Private Sub Command1_Click()

    Text1.ForeColor = vbRed

End Sub
0
 
Chandramouli kArchitectCommented:
i agree with CoatheGreat

KCM

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
PaulHewsCommented:
In what way is this question worth 150 points???
0
 
smeggheadCommented:
Do you mean that you want to display each letter in a different colour ??

In that case, you'd probably have to use the Rich-Text edit box.

Smg
0
 
mlmccCommented:
Paul
A question is worth what the asker believes or is willing to give.

0
 
sramkrisAuthor Commented:
Hi
I want to change the color of the text not just to one color but different colors for eg..if i click the button then the text foreg "Hello World" should change from say the default color to different colors.I hope this helps in clearing the question..

Thanks a lot
 
0
 
Richie_SimonettiIT OperationsCommented:
Private Sub Command1_Click()
Randomize

Text1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
0
 
sramkrisAuthor Commented:
Thanks a lot
0
 
Richie_SimonettiIT OperationsCommented:
What i don't understand is where did you have mentioned that you need a timer to get it works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.