RSS

Color To Number

Create a design form as shown below:


This application aims to find Hexa value of RGB color combination. So in addition to displays of color, in the application also produces Hexa value.

Components used include:

  1. Label
    Objects are colored Black Box
  2. Slider
    consists of three sliders, each slider object properties that you need to set the Min of your content with the number 0 and the Max you are content with the numbers 255.
  3. TextBox
    consists of 5 Textbox.

Write the source code as follows: 

Dim SlidValue(1 To 3) As Long

Private Sub mnuAbout_Click()
MsgBox frmNumbersToColors.Caption & " was written by Arthur Liberman (The Coolest " & _
"INC.)" & vbCrLf & "You can reach me at Winner5@newmail.net." & vbCrLf & _
"Credits to Oren for the idia for this program." & vbCrLf & vbCrLf & "Last modified: 01/28/2001," & _
"10:32", vbInformation, frmNumbersToColors.Caption
End Sub

Private Sub mnuExit_Click()
End
End Sub

Private Sub Slider1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(0).Text = Slider1.Value
    Text4.Text = Val(Text4.Text) - SlidValue(1) + Val(Text1(0).Text)
    SlidValue(1) = Slider1.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider1.SelLength = Slider1.Value
End Sub

Private Sub Slider2_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(1).Text = Slider2.Value
    Text4.Text = Val(Text4.Text) - (SlidValue(2) * 256) + (Val(Text1(1).Text) * 256)
    SlidValue(2) = Slider2.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider2.SelLength = Slider2.Value
End Sub

Private Sub Slider3_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(2).Text = Slider3.Value
    Text4.Text = Val(Text4.Text) - (SlidValue(3) * 65536) + (Val(Text1(2).Text) * 65536)
    SlidValue(3) = Slider3.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider3_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider3.SelLength = Slider3.Value
End Sub

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Posting Komentar