Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Go Back  Xtreme Visual Basic Talk > > > Hex Troubles and RGB Triplet


Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2017, 07:26 AM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,859
Default Hex Troubles and RGB Triplet


I'm sending a an RGB triplet through a function using the Long data type.
I use hex format as it is easy to see the triplet.
For example to send magenta color I send &HFF00FF

This works for most cases, but for all triplets that start with a triplet value of 00 ie green &H00FF00
I get an Overflow error that causes crash

&H00FF00 should = 65280
but VB changes it to
&HFF00 and this evaluates to -256 which is wrong and causes my function to crash
Reply With Quote
  #2  
Old 10-31-2017, 09:54 AM
Daigon Ali Daigon Ali is offline
Regular
 
Join Date: Aug 2014
Location: London
Posts: 59
Default

Hi,

Code:
Sub Command1_Click()
x = &HFF00 'converted from &H00FF00 by vb
hexval = "&H" & hex(x)
Msgbox CDec(hexval)
end sub
Reply With Quote
  #3  
Old 10-31-2017, 10:14 AM
dilettante's Avatar
dilettanteHex Troubles and RGB Triplet dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Pretty strange question in 2017, but try entering &H00FF00& instead. The way you are doing it tells the VB you have an Integer value, which it subsequently promotes to Long through an implicit conversion.
Reply With Quote
  #4  
Old 10-31-2017, 11:34 AM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,859
Default

Thanks all,

Adding & at end fixes problem... thanks!
Reply With Quote
Reply

Tags
triplet, rgb, troubles, hex


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
 
Hex Troubles and RGB Triplet
Hex Troubles and RGB Triplet
 
-->