|
-
Nov 29th, 2010, 09:15 AM
#1
Thread Starter
Member
Changing the colour of Text
hey i am using vb 2008, and i am trying 2 code a button that will change the colour of the font that is being entered. I want it to open a dialog box so i can choose the colour.. any help would be appreciated.
-
Nov 29th, 2010, 10:05 AM
#2
Frenzied Member
Re: Changing the colour of Text
Using a form, ColorDialog, 2 buttons and a text box. How I do it.
Code:
Public Class frmColorDialog
' declare variables to hold color values
Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer
Dim intAlpha As Integer
Private Sub btnChangeColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeColor.Click
With ColorDialog1
.ShowDialog()
intRed = .Color.R
intGreen = .Color.G
intBlue = .Color.B
intAlpha = .Color.A
txtCurrentColor.ForeColor = Color.FromArgb(intAlpha, intRed, intGreen, intBlue)
End With
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
-
Nov 29th, 2010, 06:45 PM
#3
Junior Member
Re: Changing the colour of Text
vb Code:
Public ColorChosen As Color Public ColorChose As String = ColorChosen.ToArgb Private Sub ColorButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorButton.Click ColorChosen = Me.ColorDialog1.Color ColorChose = ColorChosen.ToArgb TextBox1.ForeColor = ColorChosen ColorDialog1.Dispose() End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|