Computer Learning Zone CLZ Access Excel Word Windows

You can teach a student a lesson for a day; but if you can teach him to learn by creating curiosity, he will continue the learning process as long as he lives.

-Clay P. Bedford
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Code Vault > ASP > Fancy Text
Fancy Text
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   3 years ago

This is just something I was playing around on the website. It's called Fancy Text. It takes one random character in a string and flips the foreground and background colors. It gives you a look like this:

Not sure I'm going to keep it, but I like the code, so here it is...

Function FancyText(S, FGColor, BGColor)

    Dim L, R, F

    L = Len(S)

    Randomize
    R = 1
    While R=1 Or R=L Or Mid(S,R,1)=" "
        R = Int(L * Rnd)+1
    Wend

    F = ""
    F = F & "<" & "font style='color:" & FGColor & "; background-color:" & BGColor & "'>" & Left(s,R-1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & BGColor & "; background-color:" & FGColor & "'>" & Mid(s,R,1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & FGColor & "; background-color:" & BGColor & "'>" & Right(s,L-R) & "<" & "/font>"
    FancyText = F

End Function


I decided not to keep that version. It's a little too dramatic for my website. The artist in me likes it. The programmer / practicalist thinks it's too distracting. So I came up with this version that just switches one character to black.

Not sure I'm going to keep it, but I like the code, so here it is...

Function FancyText(S, Color1)

    Dim L, R, F

    L = Len(S)
    Color2 = "#000000"

    Randomize
    R = 1
    While R=1 Or R=L Or Mid(S,R,1)=" "
        R = Int(L * Rnd)+1
    Wend

    F = ""
    F = F & "<" & "font style='color:" & Color1 & "'>" & Left(s,R-1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & Color2 & "'>" & Mid(s,R,1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & Color1 & "'>" & Right(s,L-R) & "<" & "/font>"
    FancyText = F

End Function

There. That's better. Oh, and in case you're wondering, no you don't have to split the "<" from the rest of the text, but I need to do that to display it here or else my online editor "eats" it because it sees it as a tag in this page. So...


OK, so here's the FINAL version which I actually made into a video:

Here's the code with the color darkening function...

Function DarkenHexColor(hexColor)

    ' get rid of leading # if it exists
    If Left(hexColor,1)="#" Then hexColor=Right(hexColor,6)

    ' Convert hex color to RGB values
    r = CLng("&H" & Mid(hexColor, 1, 2))
    g = CLng("&H" & Mid(hexColor, 3, 2))
    b = CLng("&H" & Mid(hexColor, 5, 2))

    ' Reduce RGB values by 20% to darken the color
    r = Int(r * 0.6)
    g = Int(g * 0.6)
    b = Int(b * 0.6)
  
    ' Convert RGB values back to hex color
    DarkenHexColor = Right("0" & Hex(r), 2) & Right("0" & Hex(g), 2) & Right("0" & Hex(b), 2)

End Function


Function FancyText(S, Color1)

    Dim L, R, F

    L = Len(S)
    'Color2 = "#000000" ' Black
    Color2 = DarkenHexColor(Color1)

    Randomize
    R = 1
    While R=1 Or R=L Or Mid(S,R,1)=" "
        R = Int(L * Rnd)+1
    Wend

    F = ""
    F = F & "<" & "font style='color:" & Color1 & "'>" & Left(s,R-1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & Color2 & "'>" & Mid(s,R,1) & "<" & "/font>"
    F = F & "<" & "font style='color:" & Color1 & "'>" & Right(s,L-R) & "<" & "/font>"
    FancyText = F

End Function
 

There. That's much, MUCH better.

Video

You can watch the video here: ASP Fancy Text

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Fancy Text
Get notifications when this page is updated
 
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/27/2025 6:23:44 PM. PLT: 1s
Keywords: code vault asp fancy text fancytext  PermaLink  Fancy Text