Results 1 to 5 of 5

Thread: Problem with Double

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,406

    Problem with Double

    Hi to all:

    I have this code:

    Code:
    Dim laranja_melhor_volta_var  as double
    laranja_melhor_volta_var = r.Item("laranja_Melhor_tempo_volta")

    the field "laranja_Melhor_tempo_volta" return this value = 10.580

    but the variable laranja_melhor_volta_var stay with 10.58

    Info: The field to save this variable (laranja_melhor_volta_var ) in DB are defined by Number/Double with 3 decimal digits


    Question: How is the best way to keep 3 digits?


    Thanks

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: Problem with Double

    If the value is 10.58, then you only have 2 decimal places. You can display that value any way you like. Post the code you are using to display the values.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,406

    Re: Problem with Double

    Hi,


    This is the code that i have to save on DB...the display are made via Crystal reports



    Code:
    sSQL = "INSERT INTO " & eventos & " (ID, nome_piloto, carro_piloto, classe, pontos, total_voltas_metros, "
            sSQL = sSQL & "prova, pista, data, voltas_penalizacao, laranja_total_voltas, laranja_metros, Melhor_volta_laranja, "
            sSQL = sSQL & "azul_total_voltas, azul_metros, Melhor_volta_azul, amarela_total_voltas, amarela_metros, Melhor_volta_amarela, verde_total_voltas, "
            sSQL = sSQL & "verde_metros, Melhor_volta_verde, vermelha_total_voltas, vermelha_metros, Melhor_volta_vermelha, branca_total_voltas, branca_metros, Melhor_volta_branca ) "
    
            sSQL = sSQL & "VALUES (@idvar, @nome_piloto_var,  @carro_piloto_var, @classe_var, @pontos_var, @total_voltas_geral_piloto,  "
            sSQL = sSQL & "@prova_vara, @pista_var, @data_var, @voltas_penalizacao, @laranja_total_voltas_var, "
            sSQL = sSQL & "@laranja_metros_var, @laranja_melhor_volta_var, @azul_total_voltas_var, @azul_metros_var, @azul_melhor_volta_var, @amarela_total_voltas_var, @amarela_metros_var, @amarela_melhor_volta_var, "
            sSQL = sSQL & "@verde_total_voltas_var, @verde_metros_var, @verde_melhor_volta_var, @vermelha_total_voltas_var, @vermelha_metros_var, @vermelha_melhor_volta_var, @branca_total_voltas_var, @branca_metros_var, @branca_melhor_volta_var )"
    
    
    
            Dim command As New OleDb.OleDbCommand(sSQL, con)
            command.Parameters.AddWithValue("@id", idvar)
            command.Parameters.AddWithValue("@nome_piloto", nome_piloto_var)
            command.Parameters.AddWithValue("@carro_piloto", carro_piloto_var)
            command.Parameters.AddWithValue("@classe", classe_var)
            command.Parameters.AddWithValue("@pontos", pontos_var)
            command.Parameters.AddWithValue("@total_voltas_metros", total_voltas_geral_piloto)
            command.Parameters.AddWithValue("@prova", prova_var)
            command.Parameters.AddWithValue("@pista", pista_var)
            command.Parameters.AddWithValue("@data", data_var)
            command.Parameters.AddWithValue("@voltas_penalizacao", voltas_penalizacao_var)
            command.Parameters.AddWithValue("@laranja_total_voltas", total_voltas_e_metros_laranja)
            command.Parameters.AddWithValue("@laranja_metros", laranja_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_laranja", laranja_melhor_volta_var)
            command.Parameters.AddWithValue("@azul_total_voltas", total_voltas_e_metros_azul)
            command.Parameters.AddWithValue("@azul_metros", azul_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_azul", azul_melhor_volta_var)
            command.Parameters.AddWithValue("@amarela_total_voltas", total_voltas_e_metros_amarela)
            command.Parameters.AddWithValue("@amarela_metros", amarela_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_amarela", amarela_melhor_volta_var)
            command.Parameters.AddWithValue("@verde_total_voltas", total_voltas_e_metros_verde)
            command.Parameters.AddWithValue("@verde_metros", verde_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_verde", verde_melhor_volta_var)
            command.Parameters.AddWithValue("@vermelha_total_voltas", total_voltas_e_metros_vermelha)
            command.Parameters.AddWithValue("@vermelha_metros", vermelha_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_vermelha", vermelha_melhor_volta_var)
            command.Parameters.AddWithValue("@branca_total_voltas", total_voltas_e_metros_branca)
            command.Parameters.AddWithValue("@branca_metros", branca_metros_var)
            command.Parameters.AddWithValue("@Melhor_volta_branca", branca_melhor_volta_var)

    The line mark as red, store the value "10.58"

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Problem with Double

    Quote Originally Posted by sacramento View Post
    the field "laranja_Melhor_tempo_volta" return this value = 10.580

    but the variable laranja_melhor_volta_var stay with 10.58

    Info: The field to save this variable (laranja_melhor_volta_var ) in DB are defined by Number/Double with 3 decimal digits
    As the field is a numeric data type, it is stored purely as a number, which means that 10.58 is exactly the same as 10.580 and 10.5800000.

    The fact you can specify in the database system the number of digits does not mean it stores that, only that it will display that within the database software (if that is Access, then Access will display the value to 3 decimal places).

    If you want your program to show a certain number of decimal places, you need to specify that appropriately in your program.
    the display are made via Crystal reports
    In that case you need to specify that you want 3 decimal places displayed for the field within Crystal Reports somehow.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,406

    Re: Problem with Double

    OK...thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width