0

Im having a problem with my listview. When i write a decimal number on a textbox (19.22 for example) and i add it to the database, that is also set as decimal, my listview shows that number with a comma. This causes a bug that happens when i use a listview_click event to fulfill the textbox with the database data, and the textbox value returns with a comma (19,22) instead of the initial dot.

        limpacampos()
        txtid.Text = ListView1.SelectedItems(0).Text
        mskdata.Text = ListView1.SelectedItems(0).SubItems(1).Text
        tipo = ListView1.SelectedItems(0).SubItems(2).Text
        txtnome.Text = ListView1.SelectedItems(0).SubItems(3).Text

        Dim rd As MySqlDataReader
        Dim query As New MySqlCommand
        connection.Open()
        query = connection.CreateCommand
        query.CommandText = "select * from tipodedespesa where DES_DES like '%" & tipo & "%';"
        rd = query.ExecuteReader()

        If rd.Read = True Then
            combotipo.Text = tipo
        Else
            descricaooutro.Text = tipo
        End If
        connection.Close()

when i use this code the listview items don't fulfill the textbox with a dot, as it is on the database. instead of filling the textbox with 19.22 as i added, it fills with 19,22

  • 3
    What is the decimal separator in your local Language? – Jimi Mar 19 '21 at 22:31
  • it´s a comma, but i wanted to change it, i just don´t know how – André Pereira Mar 19 '21 at 22:40
  • use a differnt separator https://stackoverflow.com/a/18377793/5193536 – nbk Mar 19 '21 at 22:47
  • That's something you code for. What is the *bug that happens*? What is the exception? Where/when it happens? When you try update the database? When you parse the content of the TextBox? -- Post the code that fails, plus a description of what happens and what should happen or you'd like to happen instead. – Jimi Mar 19 '21 at 22:48
  • added the code with the description, don't know if that code is the problem tho – André Pereira Mar 20 '21 at 00:21
  • what is tipo for a datatype and pleae use **prepaored statememnts with parameters** for your queries. and take a lookm at my link it is for c# but the same is true for vb net – nbk Mar 20 '21 at 00:37

1 Answers1

0

The code that was missing is:

System.Windows.Forms.Application.CurrentCulture = New System.Globalization.CultureInfo("EN-US")

I posted it in the form load, and the listview changed the decimal separator to dot.