简体   繁体   中英

VB6 Color code to VB.NET color conversion

I am trying to convert VB6 windows forms to VB.NET forms. Now the issue is about the Color conversion. In VB6 colors codes are like HH00400040 ,H00000000 ,etc. How to convert these codes to color options available for VB.NET.Not getting any idea on these.

VB6 stores RGB color in an Int32 and assigns first byte for Blue, second for green and third for red. so you can convert int32 to bytes and use appropriate byte for rgb colors as arguments.
or easily use Color.FromArgb(Integer) method.

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. You can convert a VB6 code like &H00FBBE88& to XAML by:

  1. Dropping the front &H00 .
  2. Dropping the & at the end.
  3. Swapping first two digits with the last two, as explained in mehrdad safa's answer.
  4. Adding # in front of the string.

The resulting code would be #88BEFB . Used in a Border, it would look like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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