本文介绍了转换时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在将十六进制颜色值转换为颜色名称.

转换时,我遇到这样的错误:"ffffff80对于Int32而言不是有效值."

以下是我的代码

Hi,

I am converting hex color value into color name.

While converting, I am facing the error like this "ffffff80 is not a valid value for Int32."

Below is my code

Dim xCol As String = clspfjbs02.colrnameobj
                   Dim k As Color
                   k = System.Drawing.ColorTranslator.FromHtml(xCol)

推荐答案

Dim xCol As String = "#" & clspfjbs02.colrnameobj
Dim k As Color
k = System.Drawing.ColorTranslator.FromHtml(xCol)


Dim xCol As Int32
Dim k As Color
xCol = Int32.Parse(clspfjbs02.colrnameob, HexNumber)
k = System.Drawing.ColorTranslator.FromHtml(xCol)


k = System.Drawing.ColorTranslator.FromWin32(Integer.Parse("ffffff80", System.Globalization.NumberStyles.HexNumber))


:)


这篇关于转换时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:43