比如Color.Red --> "FF0000"

解决方案 »

  1.   

    用这个Convert.ToString()
    括号里填写要转换的string
      

  2.   

    Private Sub Paletta(ByVal TargetForm As String, _
         ByVal PalettaRow As Long, _
         ByVal Saturation As Long)
            Dim RGBColor As String
            Dim Gray As Double
            Dim lum As Double
            Dim sat As Double
            Dim hue As Double
            Dim row As HtmlTableRow
            Dim cell As HtmlTableCell
            Dim RBGcolor As String        sat = Saturation / 100
            For hue = 0 To 359 Step (360 / PalettaRow)
                row = New HtmlTableRow()
                For lum = 0.1 To 1 Step 0.02
                    cell = New HtmlTableCell()
                    HlsToRgb(hue, lum, sat, RGBColor)
                    cell.BgColor = RGBColor
                    cell.Controls.Add(New HyperLink())
                    DirectCast(cell.Controls(0), HyperLink).Text = "_"
                    DirectCast(cell.Controls(0), HyperLink).ForeColor = _
                        Color.FromArgb(Val("&h" & Mid(RGBColor, 1, 2)), _
                        Val("&h" & Mid(RGBColor, 3, 2)), _
                        Val("&h" & Mid(RGBColor, 5, 2)))
                    DirectCast(cell.Controls(0), HyperLink).NavigateUrl = _
                        TargetForm & "?&C=" & RGBColor
                    row.Cells.Add(cell)
                Next lum
                Table1.Rows.Add(row)
            Next hue
            row = New HtmlTableRow()
            For Gray = 0 To 255 Step 5.7
                cell = New HtmlTableCell()
                cell.BgColor = Right("00" & Hex(Gray), 2) & _
                   Right("00" & Hex(Gray), 2) & Right("00" & Hex(Gray), 2)
                cell.Controls.Add(New HyperLink())
                DirectCast(cell.Controls(0), HyperLink).Text = "_"
                DirectCast(cell.Controls(0), HyperLink).ForeColor = _
                   Color.FromArgb(Gray, Gray, Gray)
                DirectCast(cell.Controls(0), HyperLink).NavigateUrl = _
                   TargetForm & "?&C=" & Right("00" & Hex(Gray), 2) & _
                   Right("00" & Hex(Gray), 2) & Right("00" & Hex(Gray), 2)
                row.Cells.Add(cell)
            Next Gray
            Table1.Rows.Add(row)
        End Sub
        
        ' Converte HLS in RGB
        Private Sub HlsToRgb(ByVal H As Double, ByVal L As Double, _
              ByVal S As Double, ByRef RGBColor As String)
            Dim p1 As Double
            Dim p2 As Double
            Dim r As Double
            Dim g As Double
            Dim b As Double        If L <= 0.5 Then
                p2 = L * (1 + S)
            Else
                p2 = L + S - L * S
            End If
            p1 = 2 * L - p2
            If S = 0 Then
                r = Int(L * 255)
                g = Int(L * 255)
                b = Int(L * 255)
            Else
                r = Int(QqhToRgb(p1, p2, H + 120) * 255)
                g = Int(QqhToRgb(p1, p2, H) * 255)
                b = Int(QqhToRgb(p1, p2, H - 120) * 255)
            End If
            RGBColor = Right("00" & Hex(r), 2) & Right("00" & Hex(g), 2) & _
                Right("00" & Hex(b), 2)
        End Sub
      

  3.   

    Color mycolor=Color.Black;
    string colorstr=ColorTranslator.ToHtml(mycolor);
      

  4.   

    Color.ToArgb()
    相关的还有GetBrightness();
    GetHue();
    GetSaturation
    ();
      

  5.   

    将颜色转换为html端颜色: ColorTranslator.FromHtml("#3366cc");
    将html端颜色转换为颜色: ColorTranslator.ToHtml("Color.Red");
      

  6.   

    我刚试验过,只能得到-65536 Color.Red.ToArgb().ToString()
      

  7.   

    xrascal(横刀夺爱) 兄的是正确方法,谢谢各位