• 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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