Assalamualaikum, wr, wb..
Baiklah kali ini saya akan membahas trik membuat warna background form supaya keren, yaitu warna background form berwarna gradien.
Penasaran kan..? Ok gak usah banyak basa basi lagi kita langsung bahas, simak ya.. Siap.. hehe..
Private Sub Check1_Click()
Gradient Picture1, Slider1.Value, 0, 0, Check1.Value
Gradient Picture2, 0, Slider2.Value, 0, Check1.Value
Gradient Picture3, 0, 0, Slider3.Value, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Command1_Click()
Gradient Form1, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
End Sub
Private Sub Command2_Click()
Unload Form2
Unload Form1
End Sub
Private Sub Form_Resize()
Gradient Me, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
'SSPanel1.Left = Form1.Width / 2 - SSPanel1.Width / 2
'SSPanel1.Top = Form1.Height / 2 - SSPanel1.Height / 2
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Picture3_Paint()
Gradient Picture3, 0, 0, 255, 1
Gradient Picture4, 0, 0, 255, 1
End Sub
Private Sub Slider1_Scroll()
Label1.Caption = "Red = " + CStr(Slider1.Value)
Gradient Picture1, Slider1.Value, 0, 0, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Slider2_Scroll()
Label2.Caption = "Green = " + CStr(Slider2.Value)
Gradient Picture2, 0, Slider2.Value, 0, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Slider3_Scroll()
Label3.Caption = "Blue = " + CStr(Slider3.Value)
Gradient Picture3, 0, 0, Slider3.Value, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Buat modul baru (klik kanan pada box project sebelah kanan, pilih Add - module) ganti properti Name = grad dan masukan listing dibawah ini untuk modul.
Sub Gradient(TheObject As Object, Redval&, Greenval&, Blueval&, TopToBottom As Boolean)
Dim Step%, Reps%, FillTop%, FillLeft%, FillRight%, FillBottom%, HColor$
Step = (TheObject.Height / 63)
If TopToBottom = True Then FillTop = 0 Else FillTop = TheObject.Height - Step
FillLeft = 0
FillRight = TheObject.Width
FillBottom = FillTop + Step
For Reps = 1 To 63
TheObject.Line (FillLeft, FillTop)-(FillRight, FillBottom), RGB(Redval, Greenval, Blueval), BF
Redval = Redval - 4
Greenval = Greenval - 4
Blueval = Blueval - 4
If Redval <= 0 Then Redval = 0
If Greenval <= 0 Then Greenval = 0
If Blueval <= 0 Then Blueval = 0
If TopToBottom = True Then FillTop = FillBottom Else FillTop = FillTop - Step
FillBottom = FillTop + Step
Next
End Sub
Simpan dengan nama grad
---------------------------------->
Coba jalankan, dan geser-geser slidernya lalu klik tombol mulai, Keren kan... Selamat mencoba..
Wassalam.. n smoga bermanfaat..
Trik membuat warna gradien pada form
Baiklah kali ini saya akan membahas trik membuat warna background form supaya keren, yaitu warna background form berwarna gradien.
Penasaran kan..? Ok gak usah banyak basa basi lagi kita langsung bahas, simak ya.. Siap.. hehe..
- Seperti biasa buka program Visual Basic dan buat form baru
- Langsung saja masukan objek-objek yang diperlukan ya, berikut objek-objek yang diperlukan :
- Slider1
- Nama = slider1
- LargeChange = 10
- Max = 255
- Min = 0
- Orientation = 0-sldHorizontal
- TickFrequency = 10
- TickStyle = 0-sldBottomRight
- Slider2
- Nama = slider2
- LargeChange = 10
- Max = 255
- Min = 0
- Orientation = 0-sldHorizontal
- TickFrequency = 10
- TickStyle = 0-sldBottomRight
- Slider1
- Nama = slider3
- LargeChange = 10
- Max = 255
- Min = 0
- Orientation = 0-sldHorizontal
- TickFrequency = 10
- TickStyle = 0-sldBottomRight
- CommandButton1
- Nama = Command1
- Caption = Mulai
- CommandButton2
- Nama = Command2
- Caption = Quit!
- CheckBox
- Nama = Check1
- Caption = Dari atas kebawah
- Picture1
- Nama = Picture1
- Height = 375
- Width = 735
- Picture2
- Nama = Picture2
- Height = 375
- Width = 735
- Picture3
- Nama = Picture3
- Height = 375
- Width = 735
- Buat Label untuk masing-masing Slider dengan urutan R,G,B (Red, Green, Blue)
- Setelah semuanya beres, lalu masukan listing kode untuk setiap objeknya ya, berikut dibawah ini listing kodenya sesuaikan dengan funsi event dari setiap objeknya.
Private Sub Check1_Click()
Gradient Picture1, Slider1.Value, 0, 0, Check1.Value
Gradient Picture2, 0, Slider2.Value, 0, Check1.Value
Gradient Picture3, 0, 0, Slider3.Value, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Command1_Click()
Gradient Form1, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
End Sub
Private Sub Command2_Click()
Unload Form2
Unload Form1
End Sub
Private Sub Form_Resize()
Gradient Me, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
'SSPanel1.Left = Form1.Width / 2 - SSPanel1.Width / 2
'SSPanel1.Top = Form1.Height / 2 - SSPanel1.Height / 2
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Picture3_Paint()
Gradient Picture3, 0, 0, 255, 1
Gradient Picture4, 0, 0, 255, 1
End Sub
Private Sub Slider1_Scroll()
Label1.Caption = "Red = " + CStr(Slider1.Value)
Gradient Picture1, Slider1.Value, 0, 0, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Slider2_Scroll()
Label2.Caption = "Green = " + CStr(Slider2.Value)
Gradient Picture2, 0, Slider2.Value, 0, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Private Sub Slider3_Scroll()
Label3.Caption = "Blue = " + CStr(Slider3.Value)
Gradient Picture3, 0, 0, Slider3.Value, Check1.Value
Gradient Picture4, Slider1.Value, Slider2.Value, Slider3.Value, Check1.Value
Label5.Caption = CStr(Slider1.Value) + ", " + CStr(Slider2.Value) + ", " + CStr(Slider3.Value) + ", " + CStr(Check1.Value)
End Sub
Buat modul baru (klik kanan pada box project sebelah kanan, pilih Add - module) ganti properti Name = grad dan masukan listing dibawah ini untuk modul.
Sub Gradient(TheObject As Object, Redval&, Greenval&, Blueval&, TopToBottom As Boolean)
Dim Step%, Reps%, FillTop%, FillLeft%, FillRight%, FillBottom%, HColor$
Step = (TheObject.Height / 63)
If TopToBottom = True Then FillTop = 0 Else FillTop = TheObject.Height - Step
FillLeft = 0
FillRight = TheObject.Width
FillBottom = FillTop + Step
For Reps = 1 To 63
TheObject.Line (FillLeft, FillTop)-(FillRight, FillBottom), RGB(Redval, Greenval, Blueval), BF
Redval = Redval - 4
Greenval = Greenval - 4
Blueval = Blueval - 4
If Redval <= 0 Then Redval = 0
If Greenval <= 0 Then Greenval = 0
If Blueval <= 0 Then Blueval = 0
If TopToBottom = True Then FillTop = FillBottom Else FillTop = FillTop - Step
FillBottom = FillTop + Step
Next
End Sub
Simpan dengan nama grad
---------------------------------->
Coba jalankan, dan geser-geser slidernya lalu klik tombol mulai, Keren kan... Selamat mencoba..
Wassalam.. n smoga bermanfaat..
0 komentar:
Posting Komentar