VTW Color Chart Selector

Script

Sub InitForm
        loadColors()
End Sub

Class ColorsObj
        Public codeColor
        Public hexaColor
        Public rgbColor
        Public vtwColor
End Class

Dim arrColors()

EmptyArray()

Sub EmptyArray()
        ReDim arrColors(0)
        Set sObj = new ColorsObj
        sObj.codeColor = ""
        sObj.hexaColor = ""
        sObj.rgbColor = ""
        sObj.vtwColor = ""
        Set arrColors(0) = sObj
End sub

Sub loadColors()
        Erase arrColors
        Set XMLColors = CreateObject("Microsoft.XMLDOM")
        If XMLColors.Load("<full path to .xml file>") then
                Dim i, n
                Dim colorCount : colorCount = 0
                Set nodeRoot = XMLColors.documentElement
                If Not nodeRoot Is Nothing Then
                        Set nodeColors = nodeRoot.SelectNodes("//common/colors//color")
                        If nodeColors.Length > 0 Then
                                For i = 0 To nodeColors.Length-1
                                        ReDim Preserve arrColors(colorCount)
                                        Set sObj = new ColorsObj
                                        sObj.codeColor = nodeColors(i).getAttribute("code")
                                        sObj.hexaColor = nodeColors(i).getAttribute("hexa")
                                        sObj.rgbColor = nodeColors(i).getAttribute("rgb")
                                        sObj.vtwColor = nodeColors(i).getAttribute("vtw")
                                        Set arrColors(colorCount) = sObj
                                        colorCount = colorCount + 1
                                Next
                        End If
                End If
        Else
        End If
End sub

Function getXMLColorHexaByCode(str)
         If arrColors(0).codeColor <> "" Then
                Dim n
                For n = 0 To UBound(arrColors)
                        If str = arrColors(n).codeColor Then
                                getXMLColorHexaByCode = arrColors(n).hexaColor
                                Exit For
                        Else
                                getXMLColorHexaByCode = ""
                        End If
                Next
         End If
End Function

Function getXMLColorRgbByCode(str)
         If arrColors(0).codeColor <> "" Then
                Dim n
                For n = 0 To UBound(arrColors)
                        If str = arrColors(n).codeColor Then
                                getXMLColorRgbByCode = arrColors(n).rgbColor
                                Exit For
                        Else
                                getXMLColorRgbByCode = ""
                        End If
                Next
         End If
End Function

Function getXMLColorVTWByCode(str)
         If arrColors(0).codeColor <> "" Then
                Dim n
                For n = 0 To UBound(arrColors)
                        If str = arrColors(n).codeColor Then
                                getXMLColorVTWByCode = arrColors(n).vtwColor
                                Exit For
                        Else
                                getXMLColorVTWByCode = ""
                        End If
                Next
         End If
End Function

Sub onListCodeColorChange(Sender)
        ed_hexaColor.text = getXMLColorHexaByCode(Sender.text)
        ed_rgbColor.text = getXMLColorRgbByCode(Sender.text)

        Dim hexval : hexval = getXMLColorHexaByCode(Sender.text)

        Dim rgbval : rgbval = CLng("&h" & hexval)
        Dim r : r = (rgbval And &hff0000&) / 65536
        Dim g : g = (rgbval And &h00ff00&) / 256
        Dim b : b = (rgbval And &h0000ff&)

        ed_hexToRgb.text = Join(Array(hexval, rgbval, r, g, b), vbcrlf)
        ed_color.text = Replace(Round(r/254.99,12)&" "&Round(g/254.99,12)&" "&Round(b/254.99,12)&" 1,0",",",".")

        panel_color.Color = getXMLColorVTWByCode(Sender.text)

End sub

Color Chart .xml

<?xml version="1.0" encoding="UTF-8"?>
<common>
   <colors>
   		<color code="1" hexa="4ac8bc" rgb="74/200/188" vtw="12372042" />
        <color code="2" hexa="28a2a3" rgb="40/162/163" vtw="10723880" />
        <color code="3" hexa="209ac9" rgb="32/154/201" vtw="13212192" />		
        <color code="4" hexa="1b75b1" rgb="27/117/177" vtw="11629851" />
        <color code="5" hexa="003399" rgb="0/51/153" vtw="10040064" />
        <color code="6" hexa="001b52" rgb="0/27/82" vtw="5380864" />	
        <color code="7" hexa="010f2c" rgb="1/15/44" vtw="2887425" />
        <color code="8" hexa="882c6f" rgb="136/44/111" vtw="7285896" />
        <color code="9" hexa="b91c3b" rgb="185/28/59" vtw="3873977" />	
        <color code="10" hexa="df1f45" rgb="223/31/69" vtw="4530143" />		
        <color code="11" hexa="f34046" rgb="243/64/70" vtw="4604147" />		
        <color code="12" hexa="f5676a" rgb="245/103/106" vtw="6973429" />		
        <color code="13" hexa="e0929f" rgb="224/146/159" vtw="10457824" />		
        <color code="14" hexa="ff7900" rgb="255/121/0" vtw="31231" />		
        <color code="15" hexa="ffab37" rgb="255/171/55" vtw="3648511" />		
        <color code="16" hexa="fed22b" rgb="254/210/43" vtw="2872062" />		
        <color code="17" hexa="e1ca00" rgb="225/202/0" vtw="51937" />		
        <color code="18" hexa="b2db11" rgb="178/219/17" vtw="1170354" />		
        <color code="19" hexa="8cc129" rgb="140/193/41" vtw="2736524" />		
        <color code="20" hexa="346633" rgb="52/102/51" vtw="3368500" />		
        <color code="21" hexa="97845c" rgb="151/132/90" vtw="5932183" />		
        <color code="22" hexa="ddcead" rgb="221/206/173" vtw="11390685" />		
        <color code="23" hexa="b1ab93" rgb="177/171/147" vtw="9677745" />		
        <color code="24" hexa="b7bbbe" rgb="183/187/190" vtw="12499895" />
        <color code="25" hexa="dddddd" rgb="221/221/221" vtw="14540253" />		
   </colors>
</common>

VTW User Interface

Shopping Cart