Turn decimal into vb minutes

0
Well, I know that if I take for example 4.70 and turn the ", 70" in minutes, I have to get 0.70 (number after the comma) and multiplied by 60, which would give 42, in value of hours would be 4:42

How do I apply this in VB? How do I get the number after the comma, multiplied by 60?

    
asked by anonymous 16.04.2018 / 15:40

2 answers

1

You can get the decimal part of the number like this:

parte_decimal = (valor - Int(valor))

So you subtract the whole part, leaving only the decimal part.

    
16.04.2018 / 15:44
1

A good solution would be to use the conversion function for INT in your variable. So the difference between the two (Real - Integer) would give you the number after the comma.

Example:

Valor_Total = 4,70

valor_decimal = (Valor_Total - Int(Valor_Total))
total_minutos = valor_decimal * 60

MessageBox.Show ("Total de minutos: " + (Int(Valor_Total)ToString() + ":" + total_minutos.ToString())
  
    

Total minutes: 4:42

  

Well this is just one solution, but there are many others available!

    
16.04.2018 / 16:03