Tuesday, January 25, 2011

Convert an integer into a decimal and a decimal into an integer in Visual Basic

To convert an integer (NoFrogs) into a decimal you would use the CDbl command.

1:  Dim NoFrogs as integer
2: Dim TotalFrogs as Double
3: TotalFrogs = CDbl(NoFrogs)

To convert a decimal (NoFrogs) into an integer you would use the CInt command.

1:  Dim NoFrogs as decimal
2: Dim TotalFrogs as Integer
3: TotalFrogs = CInt(NoFrogs)

1 comment:

  1. Missing values in the variables and you converted to an int into a double rather than a decimal

    ReplyDelete