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.
Printable View
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.
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
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