Here's a somewhat cryptic version of RgbToHex I just wrote to demonstrate that we can actually do it internally with minimal external function calls (should be just the fixed string to BSTR at the end requiring an external call, edit: unless the LSet memory copies are done externally...), no conditional branching, and no slow string manipulation.
It should offer decent performance for those reasons, but I haven't benchmarked it against the other excellent answers you've already got.
Here's a somewhat cryptic version of RgbToHex I just wrote to demonstrate that we can actually do it internally with minimal external function calls (should be just the fixed string to BSTR at the end requiring an external call, edit: unless the LSet memory copies are done externally...), no conditional branching, and no slow string manipulation.
It should offer decent performance for those reasons, but I haven't benchmarked it against the other excellent answers you've already got.
Here's a somewhat cryptic version of RgbToHex I just wrote to demonstrate that we can actually do it internally with minimal external function calls (should be just the fixed string to BSTR at the end requiring an external call, edit: unless the LSet memory copies are done externally...), no conditional branching, and no slow string manipulation.
It should offer decent performance for those reasons, but I haven't benchmarked it against the other excellent answers you've already got.
Version Optimized: only for speed Optimized only for speed vs. for speed, PPro, all advanced
----------------------------------------------------------------------------------
Original 40,.101 s 40,.556 s
Cody GrayMat ́s Mug 3,38932.531 s 3,26132.154 s
CodyThunderframe Gray/Roland Illig 5,342 s 27.007 s 5,300 26.893 s
Mat ́sComintern Mug 32,5317.871 s 32,154 7.738 s
Roland Illig 5,.905 s 5,.639 s
Thunderframe Cody Gray/Roland Illig 27,0075.342 s 26,893 5.300 s
CominternCody Gray 7,871 3.389 s 7,7383.261 s
Unknown user 2,.815 s 2,.700 s
Version Optimized only for speed vs. for speed, PPro, all advanced
----------------------------------------------------------------------------------
Original 40,101 s 40,556 s
Cody Gray 3,389 s 3,261 s
Cody Gray/Roland Illig 5,342 s 5,300 s
Mat ́s Mug 32,531 s 32,154 s
Roland Illig 5,905 s 5,639 s
Thunderframe 27,007 s 26,893 s
Comintern 7,871 s 7,738 s
Unknown user 2,815 s 2,700 s
Version Optimized: only for speed for speed, PPro, all advanced
----------------------------------------------------------------------------------
Original 40.101 s 40.556 s
Mat ́s Mug 32.531 s 32.154 s
Thunderframe 27.007 s 26.893 s
Comintern 7.871 s 7.738 s
Roland Illig 5.905 s 5.639 s
Cody Gray/Roland Illig 5.342 s 5.300 s
Cody Gray 3.389 s 3.261 s
Unknown user 2.815 s 2.700 s
I tested all of the other answers' code and want to publish the results. This might help choosecompare the final implementationdifferent implementations and maybe tell us something about how to optimize VB6 code.
I tested all of the other answers' code and want to publish the results. This might help choose the final implementation and maybe tell us something about how to optimize VB6 code.
I tested all of the other answers' code and want to publish the results. This might help compare the different implementations and maybe tell us something about how to optimize VB6 code.