Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Change Text Color And Font Character By Character


Is there a way to change a single line of text, making half, one color and the other half a different color in bold?

Number of files (150) (150)

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Change Character Color Of Text Box In VB
Is It Possible To Change The Color Of Each Character Of A Text Box In VB

If So Please Give Same Sample Coding

Change Color Of Individual Character In Text Box On Error?
I am using the following code to change the color of text in Text2.Text when the user makes an error entering text displayed in Text1.Text. I would like to change the color of the error character only and this code changes color of all characters in Text2.Text. Any suggestions? Thanks!

Private Sub Text2_KeyPress(KeyAscii As Integer)
Text2.SelStart = Len(Text2.Text)
Text2.ForeColor = vbBlack
'Next lines check for end of Text1 to avoid run time errors
If Len(Text1) > Len(Text2) Then
Text1.SelStart = Text2.SelStart
Text1.SelLength = 1
If Asc(Text1.SelText) <> KeyAscii Then
Text2.ForeColor = vbRed
End If
If Text2.ForeColor = vbRed Then
End If
If KeyAscii = 8 Then 'Stops DING WAV on Backspace Key
End If
'If Text1.SelStart = Len(Text2.Text) Then
If KeyAscii = 8 Then
Text2.ForeColor = vbBlack
End If
On Error Resume Next
End If
End Sub

Reading A Text File Character-by-character

Can anyone tell me how to read individual characters from a text file, please. I need to perform substitutions on certain characters so need to be able to test each one as it is read from the file.


Display A File Character By Character In Text Box?
I have opened a file as follows and used "Common Dialog Control" (CD1). Now, I want to display the opened file character by character in a Text Box.

I have done following, but it is displaying just few first characters or the last ones.
Text1.Text = CD1.FileName

Open Text1.Text For Input As #1
Do While NOT EOF(1)
Input #1, c
Text2.Text = c
Close #1

Change Text-Box Font Color

I have a report in MS Access 2000. I would like to change the color of the font of a text box depending on certain criteria.

Example, if the date in the test box is > than Now(), I want the color of the font to be red and the text to be bold.

Can anyone help me out with this?

Thanks for your time,

Change FONT And COLOR Of A Text ...
Hi all

Very simple but I didn't find ... How can I change the FONT and COLOR of a text.
For example :
Code:MsgBox "I write in blue"(I want to see "in blue" in blue)

And when the string is a variable :
Code:Dim word As String
word = "in red"
MsgBox "I write " & word(I want to see "in red" in red)

Thanks in advance and pass a nice Summer

Rich Text Box Change Font Color
I have a sub that reads in and changes the selcolor of a rich text box.

The code executes fine and if i run the code and then write in the rich text box the text is the color set by the selcolor but if i click on a button i have set up that simply enters some text into the rich text box the text color stays black (its original color)

what do i need to do to get the text to change to the set color when it is entered like it does when its written in.

Font Color Change With In Text Line
how to change font color with in textline of label text line in runtime. That is some words need to be highlighted with different font colors.
any help pl.

How To Change The Font Color Of Disabled Text?
currently i disabled the text of various field in the program. but the disabled text appeared to be gray in color and not very visible. how can i change the font color?? pls help...

Encryption- How Can I Read From Files One Character At A Time And Output 1 Character
and output one character at a time. I already have the algorithm.

System Font And Special Character

I have one question about system fonts. Last mount I was write one aplication in VB about calculate financy in one office. This aplication was build with Croatian language character ().
In my PC this program working ok but in other PC with diferent windows in the aplication this character is lost or change. I know, this is normaly because other PC have other system fonts and code page of character. Can I change or set font and code page in other PC and in that way show specific charater of my language in Forms, menu-es, text boxes and other command?
If anybody have lots of information about programing windows font , code page and operation at them please help me to uderstand how it configure and programing in Visual Basic.
I am from Croatia (Europe).
Soory for bad English!

Max Width Of A Character In Selected Font
Hi all

I need to determined max character width in selected font.
How I can do it?

Edited by - AbbydonKrafts on 4/9/2007 5:33:53 AM

Getting Color Of A Character In An Rtf Box Without Using Seltext?
Is there a way to determine the color of a certain character in a richtextbox without highlighting it and returning the .seltext? because i'm sure it would greatly speed up my program.

How To Read Character After Character In A String?? Pease Help
Hi ,
I just can't find a way to read a string character after character ,
and I want to check each character.
On every single character i wanna do een IF-statement.
Anybody can help please?

Thanx !!

Find Character Not In Ansi Character Set With InStr

im using the InStr function to find the beginning and end of a string then using the Mid function to get the string. i can do everything fine except finding the end of the string.
i know how to use the InStr function fine, its just i dont know how to find one of those characters that are defined by a solid block in text editors (example). vb wont let me copy and paste the block character into it.

i could go through all 220ish ansi characters checking to see that it isnt any of those, but the file that i am searching through is currently 600kb and always rising and the strings are usually at least 20 characters long, so it would be more processorage intensive than i would like.

the relevant code i have at the moment is

If InStr(1, templine, "Visited: ") <> 0 Then
StartHere = InStr(1, templine, "Visited: ")
EndHere = InStr(StartHere, templine, "ARARARARARA")
End If

if anybody could give me a some advice on finding the position of this mystery block through InStr or otherwise i would appreciaite it. even a totally different approach to finding what is between the "Visited: " string and the first strange block in a file layed out something like this would be really nice.

long-winded me

Match ANSI Character To Chinese Character
Hi Guys,

Here is my problem

I have some character let s say 其它 and their respective C6E4 CBFC and
C6 =>

I believe this is DBCS to ANsi

Now i need to do the reverse function. I can get the hexadecimal code C6E4 which is 其 in Simplified Chinese Codepage 936. Having the hexadecimal value, how can i get the right character ?

THanks a million

Reading A File Character By Character Limitations
I am writing a SGML parser, and am trying to read in a .sgm file character by character so that I can check for the tags and such. I only need 2 specific child elements per parent element, so it doesnt have to be very sophisticated. Anyway, every time I try to read in a file basically using

Open sParseFilePath For Binary As 1

It works fine, until it hits around 4638 or so characters, then stops reading. Is this a limitation?

Any other suggestions on how to do this parser?


How {turn The Word Or Character A Certain Color}
how can i make it where when the user types a certain word or character it turns the word or character a certain color?

-thanks i hope to be active at this big community

Is There _fast_ Way To Acces Character.Font Object (Excel To Html)

Some time ago I builded Excel-to-html...

It can recive (slowly) bold, italic and underline as is (I've seen many exporters that do not deal with "Character.Font" object, they use just cell.font, which is 3-state: true/false/null, obviouslty they have forgot it. Or they don't know how to do it... Ou yes... it took few days...

Well, I made it... though its "light"... does not (currently) deal with "special but useless" stuff (Font size, name, borders....
These are mainly controlled through CSS... so viusally tables are dynamical...

I may post it somewhere... just leave me a note/email (I tend to forget, you know). I just have to comment it better.... (its quite "dirty & nasty" coding). In wrong hands it can easily fell apart. If some one interested... 2 classes used: htmltable & htmlcell (last one deals with font object... _cool_ thing is that tag nesting is fixed...).

BUT the question is .... is there any faster way to access Character.Font.bold... through some magic hole or something...?

How is Font object stored in file/memory? Maybe its easier to peek into memory and see "what's inside grandmas gut"?

And I do not belive each char has its own font objct.... it must be done on the fly, _I_ think... (parsed from rtf?????) so how to skip on the fly part and read needed data myself...??

Finding Width/height Of A Character Based On The Assigned Font
If I have a Label which has been assigned a specific type of Font (ie: Ms San Serif, bold 8) then how can I find what the width twips/height twips of a display character would be based on the font used?


Change The Character Before.. (RTB)
I want to know how i can change the character before the one i press now!

if i press a button in a rich text box, i want to change the char before it in the keypress, keydown or keyup sub

How do i do that?


Change Character Set At Runtime?

How would I change the character set a runtime? For example, I have a form that displays English letters on buttons and then I want to switch to another language. Some of the characters work fine in the Arial font (Western) character set, but some do not. When I switch to the Western European character set, the characters still do not display. VB inserts a "?" in place of the character.

For example, the Breve sign with a value of hex B0 (Central European will not display in far as I know.


Change Character Set At Runtime?
I'm trying to set the character set of the font properties of a control (MSFlexGrid) to display different languages.
I would like to change the character set from one to another at runtime, how to do this?

Thanks very much for replies!

How To Change A Character In A String ?
I want to change the (chr44) = , to (chr46) = . in a string nowmatter where it is

Waths the chortesd code for this?

Thanks in advance for any help


Change Password Character
My grandfather has set all kinds of passwords on his computer, but he's lost a few of them. I figured I'd be a nice guy and try to work out a solution for him. So I came up with this code to remove the password formatting of a textbox.

VB Code:
Private Sub Timer1_Timer()Dim p As POINTAPIDim handle as Long     If GetKeyState(vbLeftButton) And GK_KEYPRESSED Then        GetCursorPos p        handle = WindowFromPoint(p.x, p.y)                       SendMessage handle, EM_SETPASSWORDCHAR, 0&, 0&        Timer1.Enabled = False            End IfEnd Sub

simple enough, but it doesn't seem to work on textboxes outside of my app. Is this just the way it is, or is there a way to do this?

Change The Typed Character...
Hi people,

I have done some search work on the forums, could not find what i am looking for. Did not know exactly what kind of keywords i needed to search with. Anyway...

I want to make a program with a function to change the char you typed in something else. This function can be set on and off in the program.

- you turn the function on
- You type things in a chat screen
- if you type e, there will be a 3
- if you type a there will be an @

The goal of my program is to convert all the chars you type into funny ones...

I got differents codes about the state of key, when key is pushed etc... but I can not get it working outside the form itself...

I gues there might be some kind of API for this trick.. Anyone a hand?

Thanks in Advance, Grtz Devoney...

Inserting A Character After Every Character In A Textbox
Hello all!

I have a problem which I hope someone could help me to solve, after searching here I couldn't find what I need though

I have textbox and a button on my form, and on the buttons click event, I'd like to assign the contents of Text1 to the variable newname, after inserting a character (in this case the letter "o") in between each existing character.

To explain more clarly - if I had entered the word TEST into the textbox, then clicked the button, the variable newname would then be "ToEoSoT".

I have little experience using For, Next loops, which I assume is needed? So I think this is a good oppertinity for me to learn

Thankyou in advance

How To Read .doc File Character By Character??????
I want to read the .doc file using VB.... Will you plzzz guide me how can I read the file character by character so that i may read the specific location of the file..............

Read A File Character By Character
How would I go about reading the first character in VB from a file, then doing something with the character, reading the next character, etc.? I know how to open the file, but I don't know if there's a special mode to do it, or anything.

How To Search A String Character By Character
Hi everyone,

Need to be able to search a string and compare each character to a list of valid characters.

valid characters are a-z, A-Z, 0-9, _, -, .

this would find all these characters valid in string1 to be valid and find "=" in string2 to be invalid thus making that string an invalid string

any help or direction would be appreciated

btw i have been trying to use instr functions to accomplish this and have only been able to search
for "1" character at a time

thx harold

Reading A File Character-by-character
Hi guys

Is it possible to read a file in VB(text file ofcourse)
character-by-character, the way we do it in C ?



How Can I Change A Character In Exe File Without Injury It?
hi, i am very new here, i am from romania.
i started with qbasic and now i started learn the visual basic 6.
sorry my english knowledge

i want find something in a exe file and change it but i can't save (and open) normally.

i tryed open with opentextstream and with open file for input as
but some character missing always, exemple have some character in exe file what not text (exemple in hexa: 00,03,1b,0a).

how can i change a .exe file without injury the exe file?

How Can I Change 1st Character Of String To Uppercase
I need to change the first character in a string to uppercase. I tried using the LEN function, but I'm stumped.

For example, the name in a text is james. I want the 1st character to be uppercase, James.

Any help is appreciated.

Thanks, Chris.

Change Character In A String/textbox, Please Help
Once again I am seeking VB Cities help.

Basically I have a text box and a button. When the user types in a word containining a 'Space' (exp: The apple), and then clicks the button, I want the 'space' to be changed to '%20'.

So basically all it does is on the press of the button it changes all spaces in the string/textbox into '%20'. Thanks in advance.

Edited by - the mg on 8/22/2005 1:05:59 AM

How To Change The Font And Text Color In MsgBox(&"....&")
How can I change the Font and Text color in MsgBox("...")
ex: if I have MsgBox("Hello World"), how can I make "Hello World" font 14 and red text.


How Do To Change Multiple Character Colors In A Label Box
I am currently taking Visual Basics 6.0 classes and I am new to programming. My question is, how do I set different colors for more than one character in a label box. I am trying to make the caption "USA" in my label box red, white, and blue. I would appreciate any help accomplishing this task and be grateful for the help.

Popupmenu Background Color Change As Well As Font Size Change
hi folks
am creating one popupmenu using createpopupmenu() API
and also i insert items dynamically using insertmenuitem API
and display using Trackpopupmenu().
My problem is

1)i want to change the background color of popup menu?????
2 i want to change the font size in popup menu ???????
dynamically .
if any body know API or how to change the font size and change the background color in popupmenu ,please help ur friend.

I don't need menu editor.
i need only popup menu.
expecting a positve reply.

Change Case Type Of Each 1st Character Of A Word To Uppercase
I want to be able to convert a string so that every first character of a word gets converted to uppercase and the remaining characters are lower case.

Below are examples of existing data on the left and how I would like them to be formatted when displayed.
this is a test = This Is A Test
THIS IS a TEst = This Is A Test
THISISATEST    = Thisisatest

Msg Box; How Do I Change The Font Color And Background Color
I want a message box to pop up whenever someone opens a file. Further, I want to change the fill colors from grey and blue to something else, and I want to change the color of the fonts. Any suggestions?

How To Save Text Fontsize, Font Style And Font Color
When I save the text in a Richtextbox to a Access Database, How to save the font style and Font color with the text (Assume that user can change font style and color when they typing text into the richtextbox).

Then when I load the text from Access Database back to the Richtextbox, it should associate with it's font style and color when I was saved.

How to realize these functions???

Thanks in advance

How To Convert Upper Case Character To Lower Case Character?
Hi ,
I would like to know how to convert upper case character to lower case character. Because i am doing simple search engine. It has case sensitive.
For example, there has a keyword "Automation" in my databse, but if i type automation ,it could not be searched. just only can type Automation.
How can it automatically convert "A" to "a" then the rest of character remain the same?so that when i type automation ,it will be detected .Does anyone can help me? Can use If..Else method?

xin xin

Font Color Change
In a textbox/ richtextbox (which ever one is easier) how can I have it so that words inclosed in a "&lt;" and a "&gt;" are blue but all other colors are white? so that the this would be blue in the textbox "&lt;HR&gt;" ?

Change Font Color?
Im doing a sales problem where the end result needs to be red if negative and green if positive in the text box. Im using an if statement. What is the command to change the color to red. How do I write the code for example text4 to red.

Change Font Color
I need help please, I am trying to write a scripter.. right and I want to give a rich text box text different colors..

say I type "give item1 0" I want it to start highlighting the active commands in red.. then the rest stays blue..!


[red]give item1 0

any ideas? right now i'm using api but not very good..

i dunno :*(

How To Change Font Color?
I am using CreateFont to create fonts.


How do I change the color of the font?
I want a white font.
Thanks in advance!

Change Font Color
Hi Everyone,

Is there anyway to change the font color inside of a MsgBox. I want to have this section of the message displayed in red. " & inputbox & ". Any help would be appreciated. Thank you.

MsgBox "No Matches found for " & inputbox & ". Please try again."

Change The Font Color

I have to change the color of the text in the text ctrl. If the text is received from one text box then its color should be different from the one received to the same the text box from another text box.
That is if the text is received from Text2 to text1 then it should be in red. If the text is received from Text3 to text1 then it should be green.

This is urgent, Please help me out


Get... Say 6th Character From Text Box
ok what i want to do is to get the # character from a text box...

example of what i mean
text1.text = "i have no idea"

now i want to get say the 5 character from the text, in this example it is "v", it wont always be 5 or what not

any idea how i can do this


Change Color Of Font In Email
Can someone please tell me how to do this.

I have an Application that sends an Email for me via Outlook what I want is if a center value is true it will change the font on the subject line to a different color. Can someone tell me how do I change the color in code.

Thanks in advance

Copyright 2005-08, All rights reserved