Solved

How to change the color of the text

Posted on 2002-03-31
10
189 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
ID: 6909056
Private Sub Command1_Click()

    Text1.ForeColor = vbRed

End Sub
0
 
LVL 5

Expert Comment

by:kcm76
ID: 6909070
i agree with CoatheGreat

KCM

0
 
LVL 38

Expert Comment

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

Expert Comment

by:smegghead
ID: 6909109
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
ID: 6909521
Paul
A question is worth what the asker believes or is willing to give.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:sramkris
ID: 6909633
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
ID: 6909661
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
ID: 6910569
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
ID: 6910762
Thanks a lot
0
 
LVL 16

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

19 Experts available now in Live!

Get 1:1 Help Now