?
Solved

Well I need a text box/pic box to make the text diff colored...

Posted on 1998-12-20
5
Medium Priority
?
154 Views
Last Modified: 2010-05-03
Well see I need my rich text box/ pic box
(prefered it be a text box) to make the text diffrent colors for example:

Print "Hello" (in red)
Print "How are you today" (in blue)
End
'''
How would I go about doing this, I would really like code pls. but if have to an active X. Thanx so much!
1 more thing. I have tried ForeColor but that changed the whole text box. I need this to just make each line a diff color. Thanks so much!
0
Comment
Question by:Shroom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 

Author Comment

by:Shroom
ID: 1451669
Edited text of question
0
 
LVL 3

Accepted Solution

by:
Sendoh earned 40 total points
ID: 1451670
Hi !

The code as follow :

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long


Private Sub Command1_Click()
    Dim rc As RECT

    Picture1.ForeColor = &HFF00FF
    rc.Left = 0
    rc.Top = 0
    rc.Right = Picture1.Width
    rc.Bottom = Picture1.Height
    DrawText Picture1.hdc, "Testing", 7, rc, 0
   
    Picture1.ForeColor = &HFF0000
    rc.Left = 0
    rc.Top = 20
    rc.Right = Picture1.Width
    rc.Bottom = Picture1.Height
    DrawText Picture1.hdc, "Testing", 7, rc, 0
End Sub

Hope it'll help you !!
0
 

Author Comment

by:Shroom
ID: 1451671
I need it to be a text box, and also if i were to use a pic box
what would the code be to just make it the next line this like skipes to lines and I need it to be a suc for example:
Sub AddText(txt, color, obj as control)

can this be done or somthing similar, thanx!-
0
 

Author Comment

by:Shroom
ID: 1451672
Plus you have to adjust evry thing, to how long the text is, I need this to work no matter how long, I am making a chat program!! Thanx, sorry bout the inconvinence!
0
 

Author Comment

by:Shroom
ID: 1451673
Stamp This Code In A Module This Is The Code I figured It Out On My Own But I give U The Points Any Way!!


Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long



    Sub ColorText(txt, line, color, pbox As PictureBox)
        Dim rc As RECT
       Dim TLeng
       TLeng = Len(txt)
   
    pbox.ForeColor = color
    rc.Left = 0
    rc.Top = line * 10
    rc.Right = pbox.Width
    rc.Bottom = pbox.Height
    DrawText pbox.hdc, txt, TLeng, rc, 0
     
    End Sub

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

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 how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

718 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