PDA

View Full Version : بدست آوردن کد رنگ html



vb2005
یک شنبه 30 اردیبهشت 1386, 19:19 عصر
سلام دوستان چطور میشه ازطریق Common Dialog کد رنگ html رو بدست آورد.:متفکر:
اگه ممکنه مثال بزنید.:خجالت:

CodeMasterX
یک شنبه 30 اردیبهشت 1386, 23:34 عصر
منظورت از رنگ HTML چیه ؟
همچین استانداردی از رنگ ها نداریم،واضح تر مطرح کن لطفا.

vb2005
دوشنبه 31 اردیبهشت 1386, 01:38 صبح
منظورت از رنگ HTML چیه ؟
همچین استانداردی از رنگ ها نداریم،واضح تر مطرح کن لطفا.
مثلاً رنگ سفید در HTML به شکل زیر در میاد.
FFFFFF#
میخوام همچین کدی از رنگهای مختلف بدست بیارم,لطفاً کمک کنید.

peyman1987
دوشنبه 31 اردیبهشت 1386, 01:49 صبح
شماره های رنگ RGB رو بدست بیارین میشه سه تا شماره سه رقمی بعد تک تک به مبنای 16 تبدیلشون کنین و کنار هم بزارین آخر سر هم یه علامت # بزارین اولشون. برای مثال :
R=25,G=145,B=85
میشه
199155#
به همین راحتی

vb2005
دوشنبه 31 اردیبهشت 1386, 08:21 صبح
شماره های رنگ RGB رو بدست بیارین میشه سه تا شماره سه رقمی بعد تک تک به مبنای 16 تبدیلشون کنین و کنار هم بزارین آخر سر هم یه علامت # بزارین اولشون. برای مثال :
R=25,G=145,B=85
میشه
199155#
به همین راحتی

ممنون, ولی اگه ممکنه مثال بزنید چون هرکارمیکنم کد رنگ رو اشتباه میده. مثلاً به جای قرمز, کد سبز میده.

CodeMasterX
سه شنبه 01 خرداد 1386, 01:07 صبح
یه فرم جدید بساز و 4 تا TextBox با نام پیش فرضشون روی فرم بذار.همچنین 3 تا HScrollBar و نامشون رو به Scroll1,Scroll2,Scroll3 تغییر بده و مقدار Max شون رو به 255 ست کن.

حالا کد زیر رو برای تمام فرمت کپی کن:



Dim sR, sG, sB As String

Private Sub Form_Load()
sR = "FF"
sG = "FF"
sB = "FF"
Slider1.Value = 255
Slider2.Value = 255
Slider3.Value = 255
Text1.BackColor = RGB(255, 255, 255)
End Sub

Private Sub Slider1_Change()
Text1.BackColor = RGB(Slider1.Value, Slider2.Value, Slider3.Value)
hR = Hex(Slider1.Value)
If Len(hR) = 1 Then
sR = "0" & hR
Else
sR = hR
End If
WriteString
End Sub
Private Sub Slider2_Change()
Text1.BackColor = RGB(Slider1.Value, Slider2.Value, Slider3.Value)
hG = Hex(Slider2.Value)
If Len(hG) = 1 Then
sG = "0" & hG
Else
sG = hG
End If
WriteString
End Sub
Private Sub Slider3_Change()
Text1.BackColor = RGB(Slider1.Value, Slider2.Value, Slider3.Value)
hB = Hex(Slider3.Value)
If Len(hB) = 1 Then
sB = "0" & hB
Else
sB = hB
End If
WriteString
End Sub
Function WriteString()
Text2.Text = Slider1.Value
Text3.Text = Slider2.Value
Text4.Text = Slider3.Value
txtOut.Text = "#" & sR & sG & sB
End Function


Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text2.Text = "" Then
Text2.Text = "0"
ElseIf Not IsNumeric(Text2.Text) Then
Text2.Text = "255"
ElseIf Int(Text2.Text) > 255 Then
Text2.Text = "255"
End If
If Text3.Text = "" Then
Text3.Text = "0"
ElseIf Not IsNumeric(Text3.Text) Then
Text3.Text = "255"
ElseIf Int(Text3.Text) > 255 Then
Text3.Text = "255"
End If
If Text4.Text = "" Then
Text4.Text = "0"
ElseIf Not IsNumeric(Text4.Text) Then
Text4.Text = "255"
ElseIf Int(Text4.Text) > 255 Then
Text4.Text = "255"
End If

tR = Hex(Text2.Text)
tG = Hex(Text3.Text)
tB = Hex(Text4.Text)
Label4.Text = "#" & tR & tG & tB
Text1.BackColor = RGB(Text2.Text, Text3.Text, Text4.Text)
Slider1.Value = Text2.Text
Slider2.Value = Text3.Text
Slider3.Value = Text4.Text
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text2.Text = "" Then
Text2.Text = "0"
ElseIf Not IsNumeric(Text2.Text) Then
Text2.Text = "255"
ElseIf Int(Text2.Text) > 255 Then
Text2.Text = "255"
End If
If Text3.Text = "" Then
Text3.Text = "0"
ElseIf Not IsNumeric(Text3.Text) Then
Text3.Text = "255"
ElseIf Int(Text3.Text) > 255 Then
Text3.Text = "255"
End If
If Text4.Text = "" Then
Text4.Text = "0"
ElseIf Not IsNumeric(Text4.Text) Then
Text4.Text = "255"
ElseIf Int(Text4.Text) > 255 Then
Text4.Text = "255"
End If

tR = Hex(Text2.Text)
tG = Hex(Text3.Text)
tB = Hex(Text4.Text)
Label4.Text = "#" & tR & tG & tB
Text1.BackColor = RGB(Text2.Text, Text3.Text, Text4.Text)
Slider1.Value = Text2.Text
Slider2.Value = Text3.Text
Slider3.Value = Text4.Text
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text2.Text = "" Then
Text2.Text = "0"
ElseIf Not IsNumeric(Text2.Text) Then
Text2.Text = "255"
ElseIf Int(Text2.Text) > 255 Then
Text2.Text = "255"
End If
If Text3.Text = "" Then
Text3.Text = "0"
ElseIf Not IsNumeric(Text3.Text) Then
Text3.Text = "255"
ElseIf Int(Text3.Text) > 255 Then
Text3.Text = "255"
End If
If Text4.Text = "" Then
Text4.Text = "0"
ElseIf Not IsNumeric(Text4.Text) Then
Text4.Text = "255"
ElseIf Int(Text4.Text) > 255 Then
Text4.Text = "255"
End If

tR = Hex(Text2.Text)
tG = Hex(Text3.Text)
tB = Hex(Text4.Text)
Label4.Text = "#" & tR & tG & tB
Text1.BackColor = RGB(Text2.Text, Text3.Text, Text4.Text)
Slider1.Value = Text2.Text
Slider2.Value = Text3.Text
Slider3.Value = Text4.Text
End If
End Sub

vb2005
چهارشنبه 02 خرداد 1386, 13:07 عصر
RGB to HexaDecimal
یه فرم جدید بساز و 4 تا TextBox با نام پیش فرضشون روی فرم بذار.همچنین 3 تا HScrollBar و نامشون رو به Scroll1,Scroll2,Scroll3 تغییر بده و مقدار Max شون رو به 255 ست کن.
مشکلم حل شد متشکرم.
موفق باشید.