Visual Basic Programming Code Examples Visual Basic > Code Snippets Code Examples Change text color in a text box Change text color in a text box '2 command buttons and 1 text box required Option Explicit Private Declare Function SetSysColors Lib "user32" (ByVal nChanges _ As Long, lpSysColor As Long, lpColorValues As Long) As Long Dim NewColor(0) As Long Dim IndexArray(0) As Long Private Const COLOR_GRAYTEXT = 17 Private Sub Command1_Click() IndexArray(0) = COLOR_GRAYTEXT NewColor(0) = QBColor(Int(Rnd * 16)) SetSysColors 1, IndexArray(0), NewColor(0) End Sub Private Sub Command2_Click() Text1.Enabled = False End Sub