Imports System
Imports System.Globalization
Public Class HexToRgbConverter
Public Shared Function HexToRgb(hex As String) As (Integer, Integer, Integer)
' Remove the '#' character if present
hex = hex.TrimStart("#"c)
' Parse the hex string into an integer
Dim hexValue As Integer = Integer.Parse(hex, NumberStyles.HexNumber)
' Extract the RGB components
Dim r As Integer = (hexValue >> 16) And &HFF
Dim g As Integer = (hexValue >> 8) And &HFF
Dim b As Integer = hexValue And &HFF
Return (r, g, b)
End Function
Public Shared Sub Main()
Dim hexColor As String = "#FF5705"
Dim rgb = HexToRgb(hexColor)
Console.WriteLine($"RGB: ({rgb.Item1}, {rgb.Item2}, {rgb.Item3})")
End Sub
End Class
' run:
'
' RGB: (255, 87, 5)
'