Solved

How to change the color of the text

Posted on 2002-03-31
10
188 Views
Last Modified: 2010-05-02
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
Comment
Question by:sramkris
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 1

Expert Comment

by:COAtheGREAT
Comment Utility
Private Sub Command1_Click()

    Text1.ForeColor = vbRed

End Sub
0
 
LVL 5

Expert Comment

by:kcm76
Comment Utility
i agree with CoatheGreat

KCM

0
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
In what way is this question worth 150 points???
0
 
LVL 10

Expert Comment

by:smegghead
Comment Utility
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
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Paul
A question is worth what the asker believes or is willing to give.

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:sramkris
Comment Utility
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Private Sub Command1_Click()
Randomize

Text1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
0
 
LVL 5

Accepted Solution

by:
kcm76 earned 150 total points
Comment Utility
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
 
LVL 1

Author Comment

by:sramkris
Comment Utility
Thanks a lot
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
What i don't understand is where did you have mentioned that you need a timer to get it works.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now