• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

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..
0
sramkris
Asked:
sramkris
  • 2
  • 2
  • 2
  • +4
1 Solution
 
COAtheGREATCommented:
Private Sub Command1_Click()

    Text1.ForeColor = vbRed

End Sub
0
 
Chandramouli kArchitectCommented:
i agree with CoatheGreat

KCM

0
 
PaulHewsCommented:
In what way is this question worth 150 points???
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now