Using CByte function in VB
CByte function can be used to force byte arithmetic where multi-decimal figures are present. The following example below shows how to convert a dollar value derived from currency exchange.
Assuming we are converting 1o Euro to US Dollar using an exchange rate of 1 Euro = 1.3864 USD
Dim ExchangeRate As Double '---Variables declaration
Dim Euro, USD As Double
Dim Output As Byte
Euro = 10 '---- 10 Euro
ExchangeRate = 1.3864 '----Initialize exchange rate value
USD = Euro * ExchangeRate '---- This will gives you a figure of 13.854 in US dollar term
Output = CByte(USD) '--- Convert the data to byte arithmetic
MsgBox(Output) '---- Output value becomes 14 US Dollar
Hence, that shows how you can implement CByte function in your Visual Basic programming
See Also CType Functions
Subscribe to:
Post Comments (Atom)


0 comments
Post a Comment