Solved

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

Posted on 1998-12-20
5
152 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 10 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Suggested Courses
Course of the Month5 days, 21 hours left to enroll

627 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