简体   繁体   English

VB6 颜色代码到 VB.NET 颜色转换

[英]VB6 Color code to VB.NET color conversion

I am trying to convert VB6 windows forms to VB.NET forms.我正在尝试将 VB6 windows 窗体转换为 VB.NET 窗体。 Now the issue is about the Color conversion.现在的问题是关于颜色转换。 In VB6 colors codes are like HH00400040 ,H00000000 ,etc.在 VB6 中,颜色代码如 HH00400040、H00000000 等。 How to convert these codes to color options available for VB.NET.Not getting any idea on these.如何将这些代码转换为 VB.NET 可用的颜色选项。对这些没有任何想法。

VB6 stores RGB color in an Int32 and assigns first byte for Blue, second for green and third for red. VB6将RGB颜色存储在Int32中,并为蓝色分配第一个字节,为绿色分配第二个字节,为红色分配第三个字节。 so you can convert int32 to bytes and use appropriate byte for rgb colors as arguments. 因此您可以将int32转换为字节,并为rgb颜色使用适当的字节作为参数。
or easily use Color.FromArgb(Integer) method. 或轻松使用Color.FromArgb(Integer)方法。

Although your question states that you are using "VB.NET forms" which is probably WinForms, here's a solution for people trying to do the same using WPF.尽管您的问题表明您正在使用可能是 WinForms 的“VB.NET 表单”,但对于尝试使用 WPF 执行相同操作的人来说,这是一个解决方案。 You can convert a VB6 code like &H00FBBE88& to XAML by:您可以通过以下方式将 VB6 代码(如&H00FBBE88&转换为 XAML:

  1. Dropping the front &H00 .放下前面的&H00
  2. Dropping the & at the end.&放在最后。
  3. Swapping first two digits with the last two, as explained in mehrdad safa's answer.如 mehrdad safa 的回答中所述,将前两位数字与后两位交换。
  4. Adding # in front of the string.在字符串前面添加#

The resulting code would be #88BEFB .结果代码将是#88BEFB Used in a Border, it would look like this:在边框中使用,它看起来像这样:

<Border Background="#88BEFB">
</Border>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM